-
Notifications
You must be signed in to change notification settings - Fork 14
Fix Helidon path openapi generation #596
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
113 changes: 113 additions & 0 deletions
113
tests/test-nima-jsonb/src/main/java/org/example/OpenAPIController.java
This file contains hidden or 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,113 @@ | ||
package org.example; | ||
|
||
import java.util.List; | ||
|
||
import io.avaje.http.api.Controller; | ||
import io.avaje.http.api.Delete; | ||
import io.avaje.http.api.Get; | ||
import io.avaje.http.api.Header; | ||
import io.avaje.http.api.MediaType; | ||
import io.avaje.http.api.OpenAPIResponse; | ||
import io.avaje.http.api.OpenAPIResponses; | ||
import io.avaje.http.api.Path; | ||
import io.avaje.http.api.Post; | ||
import io.avaje.http.api.Produces; | ||
import io.avaje.http.api.Put; | ||
import io.avaje.http.api.QueryParam; | ||
import io.helidon.webserver.http.ServerRequest; | ||
import io.helidon.webserver.http.ServerResponse; | ||
import io.swagger.v3.oas.annotations.OpenAPIDefinition; | ||
import io.swagger.v3.oas.annotations.enums.SecuritySchemeIn; | ||
import io.swagger.v3.oas.annotations.enums.SecuritySchemeType; | ||
import io.swagger.v3.oas.annotations.info.Info; | ||
import io.swagger.v3.oas.annotations.security.SecurityScheme; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
|
||
@OpenAPIDefinition( | ||
info = | ||
@Info( | ||
title = "Example service", | ||
description = "Example Helidon controllers with Java and Maven")) | ||
@Controller | ||
@Path("openapi/") | ||
@SecurityScheme( | ||
type = SecuritySchemeType.APIKEY, | ||
in = SecuritySchemeIn.QUERY, | ||
name = "JWT", | ||
paramName = "access_token", | ||
description = | ||
"JSON Web Tokens are an open, industry standard RFC 7519 method for representing claims securely between two parties.") | ||
public class OpenAPIController { | ||
|
||
/** | ||
* Example of Open API Get (up to the first period is the summary). When using Javalin Context | ||
* only <br> | ||
* This Javadoc description is added to the generated openapi.json | ||
* | ||
* @return funny phrase (this part of the javadoc is added to the response desc) | ||
*/ | ||
@Get("/get") | ||
@Produces(MediaType.TEXT_PLAIN) | ||
@OpenAPIResponse(responseCode = 200, type = String.class) | ||
void ctxEndpoint(ServerRequest req, ServerResponse res) {} | ||
|
||
/** | ||
* Standard Post. uses tag annotation to add tags to openapi json | ||
* | ||
* @param b the body (this is used for generated request body desc) | ||
* @return the response body (from javadoc) | ||
*/ | ||
@Post("/post") | ||
@Tag(name = "tag1", description = "this is added to openapi tags") | ||
@OpenAPIResponse(responseCode = 200, description = "overrides @return javadoc description") | ||
@OpenAPIResponse(responseCode = 201) | ||
@OpenAPIResponse( | ||
responseCode = 400, | ||
description = "User not found (Will not have an associated response schema)") | ||
@OpenAPIResponse( | ||
responseCode = 500, | ||
description = "Some other Error (Will have this error class as the response class)", | ||
type = ErrorResponse.class) | ||
Person testPost(Person b) { | ||
return new Person(0, "baby"); | ||
} | ||
|
||
public static class ErrorResponse { | ||
|
||
public String id; | ||
public String text; | ||
} | ||
|
||
/** | ||
* Standard Post. The Deprecated annotation adds "deprecacted:true" to the generated json | ||
* | ||
* @param m the body | ||
* @return the response body (from javadoc) | ||
*/ | ||
@Deprecated | ||
@Post("/post1") | ||
@OpenAPIResponses({ | ||
@OpenAPIResponse(responseCode = 400, description = "User not found"), | ||
@OpenAPIResponse( | ||
responseCode = 500, | ||
description = "Some other Error", | ||
type = ErrorResponse.class) | ||
}) | ||
Person testPostList(List<Person> m) { | ||
return new Person(0, "baby"); | ||
} | ||
|
||
@Put("/put") | ||
@Produces(value = MediaType.TEXT_PLAIN, statusCode = 203) | ||
@OpenAPIResponse(responseCode = 204, type = String.class) | ||
String testDefaultStatus() { | ||
|
||
return "only partial info"; | ||
} | ||
|
||
@Delete("/delete/{type}") | ||
String testPathParam(String type, @QueryParam String lastName, @Header String header) { | ||
|
||
return "only partial info"; | ||
} | ||
} |
This file contains hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.