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

openapi not set in the resulting json when set to "3.1.0" in OpenApiSpec #521

Closed
agsimeonov opened this issue Oct 30, 2023 · 3 comments
Closed

Comments

@agsimeonov
Copy link

Kompendium Version:
3.14.4

Ktor version:
2.3.5

When you open the/openapi.json endpoint and openapi is set to "3.1.0" in your OpenApiSpec the resulting json doesn't have openapi set at all. If I change the version to "3.0.3" the json renders correctly.

This results in the page not rendering properly when adding the swagger(pageTitle = "Simple API Docs") route.

The page would render as so when openapi is not set in the json:
Screenshot 2023-10-30 at 12 59 07 PM

@agsimeonov agsimeonov changed the title openapi not set when OpenApiSpec is "3.1.0" openapi not set in the resulting json when set to "3.1.0" in OpenApiSpec Oct 30, 2023
@brizzbuzz
Copy link
Contributor

i wasn't able to reproduce this, my guess is that you don't have encodeDefaults set to true in your kotlix serialization config

json(Json {
  serializersModule = KompendiumSerializersModule.module
  encodeDefaults = true // <---- this
  explicitNulls = false
})

I'm also fairly certain for the other issue you opened, you just don't have the serializer module set to Kompendium (or, any other module that can handle Any)

i'm going to close this, but feel free to comment / reopen if you can't get it working. The playground module is a really good reference if you want some working code examples (would make sure you are on the proper tag tho, main is currently a bit wonky due to work for 4.0 release)

@agsimeonov
Copy link
Author

That worked. Thank you for the help!

One thing to note is that unless I set the swagger version as so:
swagger(swaggerVersion="5.9.0")

The page freezes on the latest 5.9.1. This is perhaps related to this issue here:
swagger-api/swagger-ui#9337

@brizzbuzz
Copy link
Contributor

Glad it worked for you :)

As for the swagger bug... yea seems likely... not really anything I can do there unfortunately.

Might make sense to hard code a default swagger version as the default, was thinking about doing the same for redoc.

If you want to open a PR for that I'd accept it :) tho it would get shipped in the 4.0 release

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