12

The documentation for defining general API information using the quarkus-smallrye-openapi extension is extremely sparse, and does not explain how to use all the annotations for setting up the openApi generation.

For some background, I am using a clean and largely empty project (quarkus version1.0.1.FINAL) generated from code.quarkus.io, with a single class defined as followed (With the attempted @OpenAPIDefinition annotation):

@OpenAPIDefinition(
    info = @Info(
        title = "Custom API title",
        version = "3.14"
    )
)
@Path("/hello")
public class ExampleResource {

    @GET
    @Produces(MediaType.TEXT_PLAIN)
    public String hello() {
        return "hello";
    }
}

I have eventually found that general api information (contact info, version, etc) through much digging is defined using the @OpenAPIDefinition annotation, but when used on my existing endpoint definition, no changes are made to the generated openapi specification. What am I doing wrong?

Snappawapa
  • 1,697
  • 3
  • 20
  • 42
  • Strange, this annotation seem to have no effect indeed. I also tried on a class (as demonstrated in the [specs](https://github.com/eclipse/microprofile-open-api/blob/master/spec/src/main/asciidoc/microprofile-openapi-spec.adoc#servers)) and on a package and nothing happened. I wonder if it is a bug. – Nikos Paraskevopoulos Dec 04 '19 at 10:36

1 Answers1

4

Try putting the annotation on the JAX-RS Application class. I realize you don't need one of those in a Quarkus application, but I think it doesn't hurt either. For reference in the specification TCK:

https://github.com/eclipse/microprofile-open-api/blob/master/tck/src/main/java/org/eclipse/microprofile/openapi/apps/airlines/JAXRSApp.java

  • 2
    Worked! Unfortunately just not well documented it seems. Should also be noted that you can put the same information in `src/main/resources/META-INF/openapi.yml` and the information there will be merged with the information gleaned from annotations. (meaning if you just put the `info` part in the yml, the paths will be generated for you and integrated together) – Snappawapa Dec 04 '19 at 22:15