Closed mark-roy closed 1 month ago
Hi @mark-roy may I ask you what version of openapi spec are you generating ?
@micryc Hi Michal; I see now that a version 3.0.1 spec is being generated. How do I cause it to generate version 3.1?
Thanks
Hi @mark-roy sorry for late response, If problem still exists for you here are some details to generate OAS v3.1 Depending on what tool exactly you use to generate the spec:
Swagger-Maven-Plugin: You can achieve that by adding configuration property:
<plugin>
<groupId>io.swagger.core.v3</groupId>
<artifactId>swagger-maven-plugin</artifactId>
<version>2.2.22</version>
<configuration>
<outputFileName>webhook</outputFileName>
<outputPath>src/main/java/org/example/generatedtest</outputPath>
<outputFormat>YAML</outputFormat>
<openapi31>true</openapi31> set openapi to 3.1
</configuration>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>resolve</goal>
</goals>
</execution>
</executions>
</plugin>
Exposing definition via API You can achieve that by adding configuration to your main class
@ApplicationPath("/webhooktest")
public class RestApplication extends ResourceConfig {
public RestApplication() {
OpenAPI openAPI = new OpenAPI();
openAPI.info(new Info().title("My API ").version("1.0"));
SwaggerConfiguration oasConfig = new SwaggerConfiguration()
.openAPI(openAPI)
.readAllResources(true)
.openAPI31(true); // turn on OpenApi 3.1
BaseOpenApiResource openApiResource = new OpenApiResource()
.openApiConfiguration(oasConfig);
register(openApiResource);
}
}
I am closing this ticket for now, If you will still have any problems feel free to reopen with more details
I have a project that I have been successfully generating openapi.json using Swagger annotations v2.2.22. I've taken the @Webhooks example from modules/swagger-jaxrs2/src/test/java/io/swagger/v3/jaxrs2/petstore/WebHookResource.java and added it to my project, but have not been able to get webhooks rendered in the spec file.
I've debugged the decompiled code to this point in SpecFilter, where the resourcePath is "webhook2" (from the example hook). The code then does a 'get' on that resource path and gets null on return, which it passes on to filterPathItem. Eventually this results in a NullPointerException.
Do I need to define a @Path("webhook2") somewhere? The example code doesn't seem to.