micronaut-projects / micronaut-openapi

Generates OpenAPI / Swagger Documentation for Micronaut projects
https://micronaut-projects.github.io/micronaut-openapi/latest/guide/index.html
Apache License 2.0
79 stars 93 forks source link

Classes not generated correctly when if/then is used #1797

Closed andlbrei closed 1 day ago

andlbrei commented 1 day ago

Expected Behavior

Actual Behaviour

When using if/then in an allOf to set required property I experience the following:

Steps To Reproduce

See https://github.com/andlbrei/micronaut-openapi-enum-reprod

Environment Information

MacOS 15 temurin-21

Example Application

https://github.com/andlbrei/micronaut-openapi-enum-reprod

Version

4.6.2

altro3 commented 1 day ago

All works fine, just use latest version of micronaut-openapi:

{FF707C6D-7980-4088-AE7C-6D297CDF5C9F}
altro3 commented 1 day ago

Oh, I see what problem is it now. I think json schema support (for OpenAPI 3.1.0) is very limited in openapi generator.

I checked it with openapi-generator gradle plugin with spring generator - the same. You can create an issue here: https://github.com/OpenAPITools/openapi-generator/issues

andlbrei commented 1 day ago

Ok, thanks for your quick reply!

Your documentation states that you support OpenAPI 3.X, but it should actually be 3.0?

It's hard for me to know how this library uses openapi-generator under the hood. Do you have any information you can give me on how to set up a reproduction for them that would act the same way as when using micronaut-openapi?

altro3 commented 1 day ago

We use openapi-generator like everyone else - it stores our templates, which we use to generate classes. The only difference from the standard generator is that ours is launched using our plugin. This decision was made because the openapi-generator project is almost dead and the founders of this project are no longer involved in it. And we would like to release changes more often than once every six months :-)

As for support for 3.1 - no one has tested it, as far as I understand, some things work, and some don't. Openapi-generator claims that it supports version 3.1, but as you can see, support is full of bugs. I think that in their repo you will find dozens more of the described problems.

Yes, we can fix this bug directly for micronaut in this project. But personally, I don't need it at the moment. If you want, you can do it yourself. Create a PR - we will review it and merge it.

P.S. I am not part of the micronaut team. I just like micronaut and I am a very ordinary contributor. No one stops you from doing the same ;-)

altro3 commented 1 day ago

About meesage with support OpenAPI 3.1.0:

From openapi-generator sources:

Generation using 3.1.0 specs is in development and is not officially supported yet.
If you would like to expedite development, please consider working on the open issues in the 3.1.0 project: https://github.com/orgs/OpenAPITools/projects/4/views/1
and reach out to our team on Slack at https://join.slack.com/t/openapi-generator/shared_invite/zt-12jxxd7p2-XUeQM~4pzsU9x~eGLQqX2g

From micronaut-openapi documentation:

Micronaut includes support for producing [OpenAPI](https://www.openapis.org/) (Swagger) YAML at compilation time. Micronaut will at compile time produce a OpenAPI 3.x compliant YAML file just based on the regular Micronaut annotations and the javadoc comments within your code.

Main thing: support for producing [OpenAPI](https://www.openapis.org/) (Swagger) YAML at compilation time. It means OpenAPI 3.1.0 supports by micronaut-openapi main module, not full project.

Micronaut openapi generator has the same limitations as original opanpi-generator, because it's based of it.

So, need to create an issue in openapi-generator repo