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
Generate routes and variants from OpenApi document #384
Comments
javierbrea
added a commit
that referenced
this issue
Aug 17, 2022
javierbrea
added a commit
that referenced
this issue
Aug 18, 2022
javierbrea
added a commit
that referenced
this issue
Aug 18, 2022
javierbrea
added a commit
that referenced
this issue
Aug 19, 2022
javierbrea
added a commit
that referenced
this issue
Aug 19, 2022
javierbrea
added a commit
that referenced
this issue
Aug 19, 2022
javierbrea
added a commit
that referenced
this issue
Aug 19, 2022
javierbrea
added a commit
that referenced
this issue
Aug 19, 2022
javierbrea
added a commit
that referenced
this issue
Aug 22, 2022
javierbrea
added a commit
that referenced
this issue
Aug 22, 2022
javierbrea
added a commit
that referenced
this issue
Aug 23, 2022
javierbrea
added a commit
that referenced
this issue
Aug 24, 2022
javierbrea
added a commit
that referenced
this issue
Aug 25, 2022
javierbrea
added a commit
that referenced
this issue
Aug 25, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It is desirable to support generating routes and variants automatically from an OpenApi document. The routes ids could be assigned using the method and path (
${method}-${path}
). Variants could be created using the OpenApiresponses
and their examples (${statusCode}-${exampleId}
). For defining other ids, thex-mocks-server-id
property could be used in the OpenApi document, and maybe it would be interesting also to provide a hook allowing to transform the proposed ids into another custom format.For creating the routes and variants, it could be done using different approaches:
Javascript library
A JavaScript library exporting methods for generating the routes. Collections should be added manually. For example, in a routes folder this library would be used as in:
This would allow to load OpenAPI documents from files, or to perform a request to load it from a remote server, etc. (Caution: Asyncs are not supported when loading files for the moment. Maybe the core should accept also exporting async functions apart from plain arrays when loading routes in order to allow users to generate routes from async processes)
Plugin
A plugin receiving some options could be at charge of automatically creating the routes from files in the mocks folder, or from urls. Its configuration could look like:
Both approaches are compatible and could be available at the same time, because the plugin could export the method for creating the routes while it uses it internally.
The text was updated successfully, but these errors were encountered: