-
Notifications
You must be signed in to change notification settings - Fork 96
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New Feature: OpenAPI groups and support micronaut
@Version
(#1067)
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. --------- Co-authored-by: micronaut-build <micronaut-build-account@grails.org>
- Loading branch information
1 parent
0974fe1
commit fbd4b94
Showing
48 changed files
with
2,851 additions
and
13,078 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
openapi/src/main/java/io/micronaut/openapi/annotation/OpenAPIGroup.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* Copyright 2017-2023 original authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.micronaut.openapi.annotation; | ||
|
||
import java.lang.annotation.Documented; | ||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.Target; | ||
|
||
import io.micronaut.context.annotation.AliasFor; | ||
|
||
import static java.lang.annotation.RetentionPolicy.SOURCE; | ||
|
||
/** | ||
* 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. | ||
* | ||
* @since 4.10.0 | ||
*/ | ||
@Retention(SOURCE) | ||
@Documented | ||
@Target({ElementType.PACKAGE, ElementType.TYPE, ElementType.METHOD}) | ||
public @interface OpenAPIGroup { | ||
|
||
/** | ||
* @return The names of the OpenAPi groups. | ||
*/ | ||
@AliasFor(member = "names") | ||
String[] value() default {}; | ||
|
||
/** | ||
* @return The names of the OpenAPi groups. | ||
*/ | ||
@AliasFor(member = "value") | ||
String[] names() default {}; | ||
|
||
/** | ||
* @return The names of the OpenAPi groups to exclude endpoints from. | ||
*/ | ||
String[] exclude() default {}; | ||
} |
58 changes: 58 additions & 0 deletions
58
openapi/src/main/java/io/micronaut/openapi/annotation/OpenAPIGroupInfo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* | ||
* Copyright 2017-2023 original authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.micronaut.openapi.annotation; | ||
|
||
import java.lang.annotation.Documented; | ||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Repeatable; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.Target; | ||
|
||
import io.micronaut.context.annotation.AliasFor; | ||
import io.swagger.v3.oas.annotations.OpenAPIDefinition; | ||
|
||
import static java.lang.annotation.RetentionPolicy.SOURCE; | ||
|
||
/** | ||
* With this annotation, you can specify the OpenAPIDefinition description that will be inserted | ||
* into a specific swagger file, only for this group. Thus, you can make different descriptions | ||
* for different groups. | ||
* | ||
* @since 4.10.0 | ||
*/ | ||
@Repeatable(OpenAPIGroupInfos.class) | ||
@Retention(SOURCE) | ||
@Documented | ||
@Target({ElementType.PACKAGE, ElementType.TYPE, ElementType.ANNOTATION_TYPE}) | ||
public @interface OpenAPIGroupInfo { | ||
|
||
/** | ||
* @return The names of the OpenAPi groups. | ||
*/ | ||
@AliasFor(member = "names") | ||
String[] value() default {}; | ||
|
||
/** | ||
* @return The names of the OpenAPi groups. | ||
*/ | ||
@AliasFor(member = "value") | ||
String[] names() default {}; | ||
|
||
/** | ||
* @return OpenAPI object describing information about group. | ||
*/ | ||
OpenAPIDefinition info(); | ||
} |
39 changes: 39 additions & 0 deletions
39
openapi/src/main/java/io/micronaut/openapi/annotation/OpenAPIGroupInfos.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* Copyright 2017-2023 original authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.micronaut.openapi.annotation; | ||
|
||
import java.lang.annotation.Documented; | ||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.Target; | ||
|
||
import static java.lang.annotation.RetentionPolicy.SOURCE; | ||
|
||
/** | ||
* Allows {@link OpenAPIGroupInfo} to be repeatable. | ||
* | ||
* @since 4.10.0 | ||
*/ | ||
@Documented | ||
@Retention(SOURCE) | ||
@Target({ElementType.PACKAGE, ElementType.TYPE, ElementType.ANNOTATION_TYPE}) | ||
public @interface OpenAPIGroupInfos { | ||
|
||
/** | ||
* @return An array of {@link OpenAPIGroupInfo} | ||
*/ | ||
OpenAPIGroupInfo[] value() default {}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.