Coder Social home page Coder Social logo

openapi-data-mocker's Issues

Add method to provide complete OAS spec file

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:

  1. Parse yaml or json OAS spec file and store result in static variable.
  2. Provide additional methods like:
    • 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.

Add fzaninotto/faker as optional mocking engine

It would be great to use fakerphp/faker as fake data provider because:

  1. It's well known stable solution with many features.
  2. It supports seed to generate the same values in unit tests.
  3. It generates real human examples in comparison to this package.
  4. It can generate data for different locales.

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!

Add implementation of OpenApiServerMockerInterface

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!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.