Search in sources :

Example 6 with CodegenOperation

use of io.swagger.codegen.v3.CodegenOperation in project flow by vaadin.

the class CodeGenerator method fromOperation.

@Override
public CodegenOperation fromOperation(String path, String httpMethod, Operation operation, Map<String, Schema> schemas, OpenAPI openAPI) {
    if (!"POST".equalsIgnoreCase(httpMethod)) {
        throw getGeneratorException("Code generator only supports POST requests.");
    }
    Matcher matcher = PATH_REGEX.matcher(path);
    if (!matcher.matches()) {
        throw getGeneratorException("Path must be in form of \"/<EndpointName>/<MethodName>\".");
    }
    CodegenOperation codegenOperation = super.fromOperation(path, httpMethod, operation, schemas, openAPI);
    String endpointName = matcher.group(1);
    String methodName = matcher.group(2);
    codegenOperation.getVendorExtensions().put(EXTENSION_VAADIN_CONNECT_METHOD_NAME, methodName);
    codegenOperation.getVendorExtensions().put(EXTENSION_VAADIN_CONNECT_SERVICE_NAME, endpointName);
    validateOperationTags(path, httpMethod, operation);
    return codegenOperation;
}
Also used : CodegenOperation(io.swagger.codegen.v3.CodegenOperation) Matcher(java.util.regex.Matcher)

Aggregations

CodegenOperation (io.swagger.codegen.v3.CodegenOperation)5 Handlebars (com.github.jknack.handlebars.Handlebars)1 AssignHelper (com.github.jknack.handlebars.helper.AssignHelper)1 ConditionalHelpers (com.github.jknack.handlebars.helper.ConditionalHelpers)1 StringHelpers (com.github.jknack.handlebars.helper.StringHelpers)1 io.swagger.codegen.v3 (io.swagger.codegen.v3)1 StaticHtml2Codegen (io.swagger.codegen.v3.generators.html.StaticHtml2Codegen)1 Components (io.swagger.v3.oas.models.Components)1 OpenAPI (io.swagger.v3.oas.models.OpenAPI)1 Operation (io.swagger.v3.oas.models.Operation)1 Header (io.swagger.v3.oas.models.headers.Header)1 Info (io.swagger.v3.oas.models.info.Info)1 io.swagger.v3.oas.models.media (io.swagger.v3.oas.models.media)1 RequestBody (io.swagger.v3.oas.models.parameters.RequestBody)1 ApiResponse (io.swagger.v3.oas.models.responses.ApiResponse)1 ApiResponses (io.swagger.v3.oas.models.responses.ApiResponses)1 Tag (io.swagger.v3.oas.models.tags.Tag)1 LocalDate (java.time.LocalDate)1 DateTimeFormatter (java.time.format.DateTimeFormatter)1 java.util (java.util)1