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

Swagger Version not defined and unable to render #2361

Open
SelfhostedPro opened this issue Apr 12, 2024 · 5 comments
Open

Swagger Version not defined and unable to render #2361

SelfhostedPro opened this issue Apr 12, 2024 · 5 comments

Comments

@SelfhostedPro
Copy link

Environment

latest everything (node latest LTS)

Reproduction

https://stackblitz.com/edit/github-ujxcqv?file=nitro.config.ts

Describe the bug

Swagger docs aren't visible when going to /_nitro/swagger and pops up the following error:

Unable to render this definition
The provided definition does not specify a valid version field.

Please indicate a valid Swagger or OpenAPI version field. Supported version fields are swagger: "2.0" and those that match openapi: 3.0.n (for example, openapi: 3.0.0).
image

Additional context

No response

Logs

No response

@Kasparas-G55
Copy link

Came across the same issue, stable channel of nitro is currently using swagger-ui-dist v4 CDN, which doesn't support OpenAPI 3.1.0 which is what it is set to.

Switching to nightly channel should fix your problem.

@SelfhostedPro
Copy link
Author

SelfhostedPro commented Apr 21, 2024

Ah, I thought I also ran into this on nightly. Is there a way to manually specify the OpenAPI version in the nuxt config?

@Kasparas-G55
Copy link

Kasparas-G55 commented Apr 22, 2024

Sadly it isn't possible since the value is hardcoded.

return <OpenAPI3>{
openapi: "3.1.0",
info: {
title: meta?.title,

Though you could propose to use the upcoming meta object (#2299) to allow setting OpenAPI's version and use the latest if it isn't set, but I don't really see much purpose in that, would require more discussion.

What I did as a temporary workaround: I copied the generated routes from /_nitro/openapi.json and imported them into Postman. Do note that you will need to change the info version that is currently set to null, which is a invalid schema if you're going to use this approach.

@kspace-trk
Copy link
Contributor

Hi, I expect this issue will be resolved when the version containing this Pull Request is released.
#2343

@pi0
Copy link
Member

pi0 commented Apr 23, 2024

You can try with https://nitro.unjs.io/guide/nightly

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

No branches or pull requests

4 participants