Closed drew-corporate-creations closed 2 months ago
Could you create a sample app to reproduce this bug? I use lombok + micronaut-openapi and all works fine perfectley. I think you have a wrong order of annotation processors and lombok run after micronaut openapi. That's why micronaut-openapi didn't see any fields.
Please, create a simple reproducer.
Could you create a sample app to reproduce this bug? I use lombok + micronaut-openapi and all works fine perfectley. I think you have a wrong order of annotation processors and lombok run after micronaut openapi. That's why micronaut-openapi didn't see any fields.
Please, create a simple reproducer.
I downloaded the zip from this link: https://guides.micronaut.io/latest/micronaut-openapi-swagger-ui-maven-java.html and added a class called TestClass with an @Getter and a field with @Schema. If you look in 'LatestGuidesController.java' you'll see a method that returns it.
https://github.com/drew-corporate-creations/mn-openapi
When you run ./mvnw clean install, it generates the yml, but the TestClass schema does not include field info.
As a side note, I haven't used maven in about 5 years but I used it here to ensure the reproducer is done from an existing micronaut example.
I didn't see that you a use lombok as annotation processor. You need to add this lines to pom.xml
And you will see this
And about your TestClass
: you add package private field, but didn't add setter for this field , that means you can't set this filed by deserialization. If you need to add this field to schema you need to add contructor argument or setter.
Another way add property to micronaut openapi micronaut.openapi.field.visibility.level=PACKAGE
and you will see what you want:
micronaut.openapi.field.visibility.level=PACKAGE solved the problem! Thank you.
I checked the micronaut docs and do see it nestled there in 6.4: https://micronaut-projects.github.io/micronaut-openapi/latest/guide/
The sample code from here: https://guides.micronaut.io/latest/micronaut-openapi-swagger-ui-maven-java.html uses 'record' classes. And the code form here: https://micronaut-projects.github.io/micronaut-openapi/latest/guide/ uses private fields with explicit public accessors.
Expected Behavior
Fields in object schemas should be generated when using lombok. Instead, the generated code is missing all fields.
Actual Behaviour
The generated code is missing all fields. The output looks something like this:
Steps To Reproduce
Using the micronaut sample: https://guides.micronaut.io/latest/micronaut-openapi-swagger-ui-maven-java.html
Add the lombok plugin to the pom file: https://mvnrepository.com/artifact/org.projectlombok/lombok-maven-plugin/1.18.20.0
Create a class called 'TestResponse' with a few string fields. Add the @Getter annotation to the top of the class.
Add a controller method that returns the TestResponse object.
./mvnw clean install
Note that the yml output does not include the fields.
Environment Information
No response
Example Application
No response
Version
4.6.1