Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] Run OpenAPI / Swagger Docs #24

Open
goatandsheep opened this issue Apr 16, 2019 · 8 comments
Open

[Feature Request] Run OpenAPI / Swagger Docs #24

goatandsheep opened this issue Apr 16, 2019 · 8 comments

Comments

@goatandsheep
Copy link

I have exported a swagger API and I'm wondering if I can use this as the README doesn't explain what this package does.

@pateketrueke
Copy link
Member

This package will take valid json-schema sources form any given directory and then expose them as REST endpoints, su you can query them to produce random values.

Se how the server.test.js is working.

@goatandsheep
Copy link
Author

@pateketrueke okay so to be clear, will it use the paths attribute to determine what the endpoints look like?

@pateketrueke
Copy link
Member

It uses the filenames as endpoint paths, e.g.

$ json-schema-server path/to/schemas -p 5000
path/to/schemas/Example.json => localhost:5000/Example

@goatandsheep
Copy link
Author

I'm going to change this to a feature request

@goatandsheep goatandsheep changed the title [Question] Can this run using OpenAPI / Swagger? [Feature Request] Run OpenAPI / Swagger Docs Apr 17, 2019
@pateketrueke
Copy link
Member

Please provide your input as starting point, I'm no very familiar with OpenAPI/Swagger to accomplish this by myself.

@goatandsheep
Copy link
Author

goatandsheep commented May 2, 2019

This is the spec for OpenAPI. It has a paths object that hold the routes. Each of these paths has a set of properties set for each response code. It fits very nicely with json-schema-faker. Here's an example of a route from the link:

{
  "/pets": {
    "get": {
      "description": "Returns all pets from the system that the user has access to",
      "responses": {
        "200": {          
          "description": "A list of pets.",
          "content": {
            "application/json": {
              "schema": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/pet"
                }
              }
            }
          }
        }
      }
    }
  }
}

@goatandsheep
Copy link
Author

goatandsheep commented May 2, 2019

The OpenAPI uses the content object and json-schema-faker uses properties. So it would have to be converted to the appropriate format, but within the properties themselves, it's the same.

@pateketrueke
Copy link
Member

Gotcha, but I think probably there are already solutions for this.

I don't want to clutter this module just to support OpenAPI, please review here to see if something fit to your needs.

Otherwise it's possible to integrate, at least, the routing part from the spec but I'm not sure how complicated it'll be.

So much thanks for your feedback!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants