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

api versioning? #8

Open
airtonix opened this issue May 17, 2020 · 1 comment
Open

api versioning? #8

airtonix opened this issue May 17, 2020 · 1 comment

Comments

@airtonix
Copy link

airtonix commented May 17, 2020

how do we spec different api versions?

/api/v1
  / -> returns openapi.json for version 1
  /food -> returns list of all our food
/api/v2
  / -> returns openapi.json for version 2
  /apples -> returns our food that is apples
  /oranges -> returns our food that is oranges

I Haven't dived into it yet, but It looks like you can only define one openapi3 schema for the entire server?

If I'm wrong then i'd also like to define that an endpoint is part of a different openapi3.server (a way to show in the ui that your api has several versions of endpoints)

Then users can jump between the available versions of my api

@airtonix
Copy link
Author

airtonix commented May 17, 2020

So as an update of what I've discovered/attempted so far:

  await OAS.OpenapiModule.attach({
    app,
    baseLogger: console,
    document: await buildOpenapiDocument(app),
    apiDocs: 'rapidoc',
  })

This results in http://localhost:400/api-docs/ rendering the RapiDoc interface... as expected.

When I try to mount it on another baseUrl:

  await OAS.OpenapiModule.attach({
    app,
    baseLogger: console,
    document: await buildOpenapiDocument(app),
    apiDocs: 'rapidoc',
    baseUrl: 'api/v1'
  })

I see the following:

  • breakpoints within @eropple/nestjs-openapi3/dist/openapi.module.js are hit and the httpAdapter.get(apiDocsPath, (req, res) => res.contentType('html').send(rapidocHtml)); is setup. apiDocsPath here is api/v1/api-docs not /api/v1/api-docs
  • making requests to http://localhost:4000/api/v1/openapi.json results in a 404
  • making requests to http://localhost:4000/api/v1/api-docs results in a 404

Ideally I'd like :

  • The document generator to only deal with creating the openapi.json
  • Some way of mounting the openapi.json Document Generator at different api endpoints /api/v1/openapi3.json , /api/v2/openapi3.json, etc (I'm new to nestjs so I'm not sure the best way ideal way to do this perhaps as a root controller in a module?)
  • To provide my own Controller that returns a html template containing my own implementation of RapiDoc

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

1 participant