-
Notifications
You must be signed in to change notification settings - Fork 94
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
New Feature: OpenAPI groups and support micronaut @Version
#1067
New Feature: OpenAPI groups and support micronaut @Version
#1067
Conversation
Does it automatically generate groups for |
Not really. Versions and groups are different entities. You can use only versions or only groups, or you can use groups and versions together.
|
openapi/src/main/java/io/micronaut/openapi/annotation/OpenAPIGroup.java
Outdated
Show resolved
Hide resolved
* @return The names of the OpenAPi groups. | ||
*/ | ||
@AliasFor(member = "value") | ||
String[] names() default {}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would use one aliasFor depending which value is going to be read
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm sorry, I don't understand what you're suggesting?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The is no point to have two AliasFor
, choose one property that you are going to use for reading (names
) and only use one alias for value
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It’s not wrong. Essentially you are going to read only one property like names or value, so it doesn’t make sense to map the value to the other value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as I understand, AliasFor serves to make the annotations more understandable and at the same time leave the ability to write simple annotations without additional property specification. My case is just right for this:
The OpenAPIGroup annotation has 2 fields - names and exclude.
If you specify both values, then we will write like this: @OpenAPIGroup(names = "g1", exclude = "g2")
.
But often you do not need to specify the groups from which to exclude this endpoint, then the annotation will look like this:
@OpenAPIGroup("g1")
. Whihout AliasFor i need to write annotation like this: @OpenAPIGroup(names = "g1")
openapi/src/main/java/io/micronaut/openapi/visitor/group/RouterVersioningProperties.java
Show resolved
Hide resolved
openapi/src/test/groovy/io/micronaut/openapi/visitor/OpenApiVersionSpec.groovy
Show resolved
Hide resolved
This needs to target next major version |
Am I correct that you are also modifying the swagger UI? I don't know if that is the best idea. We would have to maintain it instead of copy https://swagger.io/tools/swagger-ui/ files. Does it produce multiple swagger definitions? |
@dstepanov Yes, redoc and rapidoc can't do it out of the box, but swagger-ui supports it out of the box. I didn't change anything in the swagger-ui code. Why we can't release it with micronaut 3.X ????? |
Why did you modify openapi/src/main/resources/templates/swagger-ui/theme/monokai.css I think there are a lot of changes, and v4 will be released soon. WDYT @graemerocher |
@dstepanov Not a lot changes. Old functionality works the a as before. This is just new feature. I described changes css files:
this is not modified file, just minimized to reduce files size |
Do you know if we update Swagger UI? |
I don't understand. Nobody updates anything, everything is gone as before, I just minimized the theme files for the swagger ui. By the way, it does not belong to swagger ui, this is a separate project of enthusiasts. |
My screenshot has a dark theme enabled. If it bothers you, I can take a screenshot with the default theme :-) |
I know we have a copy of Swagger UI. We might want to update it if there is a newest version |
Well, that's what I do. For example here: #1070 It's just that I don't understand why you are talking about updating the swagger UI if these changes do not affect it? |
Nothing about this PR. I was just wondering if we do update it 😄 |
I've been updating since I added it here ;-) |
yeah this should target 4.x only IMO |
Personally, I would not want to wait a few more months before the release of the final release 4.0, which most likely cannot be switched to for some time due to bugs (no matter how you test, and after such serious changes there will definitely be bugs). In addition, micronaut 4 requires java 17, not everyone has switched to java 17 (even I have a couple of services still running on java 8). These changes do not affect the previous functionality in any way - it works the same as it worked. I can't call it a major change. Just extra functionality. |
Minimize swagger-ui themes
This should definitely target at least a minor release 4.10 but I don't think we plan to release a new minor Micronaut 3.X so it would be better to target v4. |
Branch 3.10 has been created for you, I think you will not abandon macronaut version 3, because not everyone will be able to knit and it’s so easy to switch from micronaut 3 to micronaut 4. And few will do it right away. As I said, there will definitely be bugs, and it will also take time due to some changes in the code (for example, change javax to jakarta and maybe something else) and few people are ready to risk correct operation of the system just to switch to a new major version. In general, I look at this issue as a realist. You have changed the system requirements too much to use micronaut 4. Because of this, it will not be possible to use third-party features that are not directly related to micronaut (like the openapi generator) without switching to the new version of micronaut. It seems to me that your versioning strategy is not entirely correct. It's impossible to develop libraries properly, regardless of micronaut-core.... :-( In any case, if I were you, I would be ready to release 3.10. Most likely it will be required |
I guess you can target 4.10, and we will release a new minor version. WDYT @graemerocher |
Fixed documentation about views properties
# Conflicts: # gradle.properties
build is failing |
@graemerocher that was not my fault. Just some problems with gradle repo with your build plugin. I restarted build and now all is ok. |
Thanks for the contribution! |
Introducing a new feature: openapi groups (the same feature as in springdoc-openapi). Now you can group endpoints to get multiple swagger files - one file for each group. This is useful when you have multiple API versions or want to separate your API based on some other criteria.
The group settings are very flexible (it was possible to add more settings, but for the first version of the feature it is quite enough). So, a brief introduction to the feature:
With this annotation, you can specify one or more groups that this endpoint will be included in, as well as specify groups from which this endpoint should be excluded.
In addition, the following was done:
Added support for annotation Version: processing of this annotation is about the same as for groups. The API description is divided into several files for each version. Query parameters or headers specified in the versioning settings are added to the description of endpoints.
Versioning can be combined with groups, so each group will have several different files for each version.
css files of swagger UI themes are replaced with minimized copies.
Fixed #952
Fixed #786