@Test public void testStandardScenario() throws Exception { File testPom = new File(getBasedir(), "src/test/resources/unit/generate-open-api-standard/pom.xml"); GenerateOpenApiSchemaMojo mojo = (GenerateOpenApiSchemaMojo) lookupMojo("generateOpenApi", testPom); mojo.execute(); }
public void execute() { OpenAPIGenerator openApiGenerator = new OpenAPIGenerator( asList(modelPackages), asList(controllerBasePackages), createInfoFromParameters(), parseInputInterceptors(schemaInterceptors, SchemaInterceptor.class), parseInputInterceptors(schemaFieldInterceptors, SchemaFieldInterceptor.class), parseInputInterceptors(operationParameterInterceptors, OperationParameterInterceptor.class), parseInputInterceptors(operationInterceptors, OperationInterceptor.class), parseInputInterceptors(requestBodyInterceptors, RequestBodyInterceptor.class), parseInputFilter(operationFilter, OperationFilter.class), parseInputFilter(operationParameterFilter, OperationParameterFilter.class), parseInputFilter(schemaFieldFilter, SchemaFieldFilter.class) ); OpenApiGeneratorConfig openApiGeneratorConfig = OpenApiGeneratorConfigBuilder.defaultConfig().build(); if (BooleanUtils.isTrue(generateExamples)) { openApiGeneratorConfig.setGenerateExamples(true); if (StringUtils.isNotBlank(openApiExamplesResolver)) { openApiGeneratorConfig.setOpenApiExampleResolver(instantiateClass(openApiExamplesResolver, OpenApiExampleResolver.class)); } } OpenAPI openAPI = openApiGenerator.generate(openApiGeneratorConfig); ObjectMapper objectMapper = new ObjectMapper(); objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); try { if (!new File(outputDirectory).mkdirs()) { getLog().error(String.format("Error creating directories for path [%s]", outputDirectory)); return; } objectMapper.writeValue(new File(outputDirectory + "/swagger.json"), openAPI); } catch (IOException e) { getLog().error("Cannot serialize generated OpenAPI spec", e); } }
GenerateOpenApiSchemaMojo extends AbstractMojo { public void execute() { OpenAPIGenerator openApiGenerator = new OpenAPIGenerator( asList(modelPackages), asList(controllerBasePackages), createInfoFromParameters(), parseInputInterceptors(schemaInterceptors, SchemaInterceptor.class), parseInputInterceptors(schemaFieldInterceptors, SchemaFieldInterceptor.class), parseInputInterceptors(operationParameterInterceptors, OperationParameterInterceptor.class), parseInputInterceptors(operationInterceptors, OperationInterceptor.class), parseInputInterceptors(requestBodyInterceptors, RequestBodyInterceptor.class), parseInputFilter(operationFilter, OperationFilter.class), parseInputFilter(operationParameterFilter, OperationParameterFilter.class), parseInputFilter(schemaFieldFilter, SchemaFieldFilter.class) ); OpenApiGeneratorConfig openApiGeneratorConfig = OpenApiGeneratorConfigBuilder.defaultConfig().build(); if (BooleanUtils.isTrue(generateExamples)) { openApiGeneratorConfig.setGenerateExamples(true); if (StringUtils.isNotBlank(openApiExamplesResolver)) { openApiGeneratorConfig.setOpenApiExampleResolver(instantiateClass(openApiExamplesResolver, OpenApiExampleResolver.class)); } } OpenAPI openAPI = openApiGenerator.generate(openApiGeneratorConfig); ObjectMapper objectMapper = new ObjectMapper(); objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); try { if (!new File(outputDirectory).mkdirs()) { getLog().error(String.format("Error creating directories for path [%s]", outputDirectory)); return; } objectMapper.writeValue(new File(outputDirectory + "/swagger.json"), openAPI); } catch (IOException e) { getLog().error("Cannot serialize generated OpenAPI spec", e); } } }
GenerateOpenApiSchemaMojo extends AbstractMojo { public void execute() { OpenAPIGenerator openApiGenerator = new OpenAPIGenerator( asList(modelPackages), asList(controllerBasePackages), createInfoFromParameters(), parseInputInterceptors(schemaInterceptors, SchemaInterceptor.class), parseInputInterceptors(schemaFieldInterceptors, SchemaFieldInterceptor.class), parseInputInterceptors(operationParameterInterceptors, OperationParameterInterceptor.class), parseInputInterceptors(operationInterceptors, OperationInterceptor.class), parseInputInterceptors(requestBodyInterceptors, RequestBodyInterceptor.class), parseInputFilter(operationFilter, OperationFilter.class), parseInputFilter(operationParameterFilter, OperationParameterFilter.class), parseInputFilter(schemaFieldFilter, SchemaFieldFilter.class) ); OpenApiGeneratorConfig openApiGeneratorConfig = OpenApiGeneratorConfigBuilder.defaultConfig().build(); if (BooleanUtils.isTrue(generateExamples)) { openApiGeneratorConfig.setGenerateExamples(true); if (StringUtils.isNotBlank(openApiExamplesResolver)) { openApiGeneratorConfig.setOpenApiExampleResolver(instantiateClass(openApiExamplesResolver, OpenApiExampleResolver.class)); } } OpenAPI openAPI = openApiGenerator.generate(openApiGeneratorConfig); ObjectMapper objectMapper = new ObjectMapper(); objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); try { if (!new File(outputDirectory).mkdirs()) { getLog().error(String.format("Error creating directories for path [%s]", outputDirectory)); return; } objectMapper.writeValue(new File(outputDirectory + "/swagger.json"), openAPI); } catch (IOException e) { getLog().error("Cannot serialize generated OpenAPI spec", e); } }  }
GenerateOpenApiSchemaMojo extends AbstractMojo { public void execute() { OpenAPIGenerator openApiGenerator = new OpenAPIGenerator( asList(modelPackages), asList(controllerBasePackages), createInfoFromParameters(), parseInputInterceptors(schemaInterceptors, SchemaInterceptor.class), parseInputInterceptors(schemaFieldInterceptors, SchemaFieldInterceptor.class), parseInputInterceptors(operationParameterInterceptors, OperationParameterInterceptor.class), parseInputInterceptors(operationInterceptors, OperationInterceptor.class), parseInputInterceptors(requestBodyInterceptors, RequestBodyInterceptor.class), parseInputFilter(operationFilter, OperationFilter.class), parseInputFilter(operationParameterFilter, OperationParameterFilter.class), parseInputFilter(schemaFieldFilter, SchemaFieldFilter.class) ); OpenApiGeneratorConfig openApiGeneratorConfig = OpenApiGeneratorConfigBuilder.defaultConfig().build(); if (BooleanUtils.isTrue(generateExamples)) { openApiGeneratorConfig.setGenerateExamples(true); if (StringUtils.isNotBlank(openApiExamplesResolver)) { openApiGeneratorConfig.setOpenApiExampleResolver(instantiateClass(openApiExamplesResolver, OpenApiExampleResolver.class)); } } OpenAPI openAPI = openApiGenerator.generate(openApiGeneratorConfig); ObjectMapper objectMapper = new ObjectMapper(); objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); try { if (!new File(outputDirectory).mkdirs()) { getLog().error(String.format("Error creating directories for path [%s]", outputDirectory)); return; } objectMapper.writeValue(new File(outputDirectory + "/swagger.json"), openAPI); } catch (IOException e) { getLog().error("Cannot serialize generated OpenAPI spec", e); } }  void execute(); }
GenerateOpenApiSchemaMojo extends AbstractMojo { public void execute() { OpenAPIGenerator openApiGenerator = new OpenAPIGenerator( asList(modelPackages), asList(controllerBasePackages), createInfoFromParameters(), parseInputInterceptors(schemaInterceptors, SchemaInterceptor.class), parseInputInterceptors(schemaFieldInterceptors, SchemaFieldInterceptor.class), parseInputInterceptors(operationParameterInterceptors, OperationParameterInterceptor.class), parseInputInterceptors(operationInterceptors, OperationInterceptor.class), parseInputInterceptors(requestBodyInterceptors, RequestBodyInterceptor.class), parseInputFilter(operationFilter, OperationFilter.class), parseInputFilter(operationParameterFilter, OperationParameterFilter.class), parseInputFilter(schemaFieldFilter, SchemaFieldFilter.class) ); OpenApiGeneratorConfig openApiGeneratorConfig = OpenApiGeneratorConfigBuilder.defaultConfig().build(); if (BooleanUtils.isTrue(generateExamples)) { openApiGeneratorConfig.setGenerateExamples(true); if (StringUtils.isNotBlank(openApiExamplesResolver)) { openApiGeneratorConfig.setOpenApiExampleResolver(instantiateClass(openApiExamplesResolver, OpenApiExampleResolver.class)); } } OpenAPI openAPI = openApiGenerator.generate(openApiGeneratorConfig); ObjectMapper objectMapper = new ObjectMapper(); objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); try { if (!new File(outputDirectory).mkdirs()) { getLog().error(String.format("Error creating directories for path [%s]", outputDirectory)); return; } objectMapper.writeValue(new File(outputDirectory + "/swagger.json"), openAPI); } catch (IOException e) { getLog().error("Cannot serialize generated OpenAPI spec", e); } }  void execute();  }