Search in sources :

Example 6 with JavadocBlockTag

use of com.github.javaparser.javadoc.JavadocBlockTag in project flow by vaadin.

the class OpenAPIObjectGenerator method createApiSuccessfulResponse.

private ApiResponse createApiSuccessfulResponse(MethodDeclaration methodDeclaration, ResolvedTypeParametersMap resolvedTypeParametersMap) {
    Content successfulContent = new Content();
    // "description" is a REQUIRED property of Response
    ApiResponse successfulResponse = new ApiResponse().description("");
    methodDeclaration.getJavadoc().ifPresent(javadoc -> {
        for (JavadocBlockTag blockTag : javadoc.getBlockTags()) {
            if (blockTag.getType() == JavadocBlockTag.Type.RETURN) {
                successfulResponse.setDescription("Return " + blockTag.getContent().toText());
            }
        }
    });
    if (!methodDeclaration.getType().isVoidType()) {
        MediaType mediaItem = createReturnMediaType(methodDeclaration, resolvedTypeParametersMap);
        successfulContent.addMediaType("application/json", mediaItem);
        successfulResponse.content(successfulContent);
    }
    return successfulResponse;
}
Also used : Content(io.swagger.v3.oas.models.media.Content) MediaType(io.swagger.v3.oas.models.media.MediaType) ApiResponse(io.swagger.v3.oas.models.responses.ApiResponse) JavadocBlockTag(com.github.javaparser.javadoc.JavadocBlockTag)

Aggregations

JavadocBlockTag (com.github.javaparser.javadoc.JavadocBlockTag)6 Javadoc (com.github.javaparser.javadoc.Javadoc)4 Test (org.junit.Test)4 Content (io.swagger.v3.oas.models.media.Content)2 MediaType (io.swagger.v3.oas.models.media.MediaType)2 ArraySchema (io.swagger.v3.oas.models.media.ArraySchema)1 ComposedSchema (io.swagger.v3.oas.models.media.ComposedSchema)1 MapSchema (io.swagger.v3.oas.models.media.MapSchema)1 ObjectSchema (io.swagger.v3.oas.models.media.ObjectSchema)1 Schema (io.swagger.v3.oas.models.media.Schema)1 RequestBody (io.swagger.v3.oas.models.parameters.RequestBody)1 ApiResponse (io.swagger.v3.oas.models.responses.ApiResponse)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1