-
Notifications
You must be signed in to change notification settings - Fork 102
OpenAPI generator doesn't correctly handle data class schema references #414
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
Comments
I imagine it's this function ( https://github.com/micronaut-projects/micronaut-openapi/blob/master/openapi/src/main/java/io/micronaut/openapi/visitor/AbstractOpenApiEndpointVisitor.java#L380 ) that doesn't seem to have anything specific for nullable or Optional types? I also noticed that wrapping it in an I put up an attempt at a fix here and would appreciate some feedback and best ways to write test for this: https://github.com/micronaut-projects/micronaut-openapi/pull/415/files |
@alvarosanchez looking at this bug a bit more holistically i think the nullable types is a red-herring. The issue seems to be that it's no longer generating references correctly. See my original example and change the type of address from |
Could you please share an application that reproduces the issue so that we can investigate? |
@alvarosanchez i tried to reproduce this in a standalone fashion but i couldn't (here's the attempt: https://github.com/pratik-brex/micronaut-demo/tree/ptandel/openapi_issue ) Our internal repository is using Bazel (instead of Gradle) and it's possible that that could potentially be a problem. We're using the same annotation processors defined here: https://github.com/micronaut-projects/micronaut-core/blob/2.2.x/inject-java/src/main/resources/META-INF/services/javax.annotation.processing.Processor Were there any changes to how annotation processors were being handled or should i add new annotation processors? I noticed this PR might have included new annotation processors? #364 -- however it's interesting that most of the OpenAPI processors are working except for this example I showed below Note: I noticed that downgrading Micronaut-OpenAPI to 2.1.3 didn't necessarily fix the issues. Our schema is defined in a different target (effectively a different JAR) than the controllers / application, so i wonder if that's possible. The strange thing is that it's setting a
|
So upon further digging, this seems to be the underlying issue: OpenAPI doesn't allow In the repro above, the micronaut generator is setting |
Uh oh!
There was an error while loading. Please reload this page.
Thanks for reporting an issue, please review the task list below before submitting the
issue. Your issue report will be closed if the issue is incomplete and the below tasks not completed.
NOTE: If you are unsure about something and the issue is more of a question a better place to ask questions is on Stack Overflow (https://stackoverflow.com/tags/micronaut) or Gitter (https://gitter.im/micronautfw/). DO NOT use the issue tracker to ask questions.
Task List
In Kotlin 1.3 and Micronaut 2.2.0 when a field had a type (lets say
Address?
in this case) was specified for adata class
it would correctly compute generate the spec as:class Foo(val address: Address)
However with the upgrade to Kotlin 1.4 and the newest Micronaut upgrade (2.0.3 to 2.2.0), it doesn't generate the
$ref
correctly and generates it as anobject
type instead:Steps to Reproduce
Expected Behaviour
Tell us what should happen
Actual Behaviour
Tell us what happens instead
Environment Information
Example Application
The text was updated successfully, but these errors were encountered: