ybelenko / openapi-data-mocker Goto Github PK
View Code? Open in Web Editor NEWLibrary that generates fake data from OpenAPI 3.0 Spec
License: MIT License
Library that generates fake data from OpenAPI 3.0 Spec
License: MIT License
Package accepts deserialized parts of OAS spec as arguments right now. However, it might be much more convenient to specify path to complete OAS spec file and use only operation/model names to mock data.
As a conclusion, package should:
yaml
or json
OAS spec file and store result in static variable.mockModelFromSpec(string $modelName)
mockOperationFromSpec(string $operationId)
mockResponseFromSpec(string $operationId, string $responseStatusCode = 'default', string $mediaType = null)
.I guess there might be issues with specs divided into many referenced files, but it's not common case and can be fixed afterwards.
It would be great to use fakerphp/faker
as fake data provider because:
seed
to generate the same values in unit tests.The only disadvantage of fzaninotto/faker
is library size(3.5MB). That's why I'm going to add it as suggest
package, not required.
I submit this issue just to show what I'm working on right now!
Ref: OpenAPI Specification 3.1.0 - Composition and Inheritance (Polymorphism)
Current Mocker ignores allOf
property, so it's not possible to use composition in models.
Mocker should merge components joined by allOf
refs.
I'm creating first implementation of OpenAPIServer\Mock\OpenApiServerMockerInterface
This class is crucial for server unit tests.
For example, when I need to test createUser
API operation I need to mock valid Psr\Http\Message\ServerRequestInterface
instance based on OAS3.0 Path Item Object and pass it to server handler. That's what OpenAPIServer\Mock\OpenApiServerMockerInterface::mockRequest
method has been created for:
public function mockRequest(
string $path,
string $method,
?array $parameters = null,
?array $requestBody = null,
?array $security = null,
?array $callbacks = null
): ServerRequestInterface;
I submit this issue just to show what I'm working on right now!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.