Forum Discussion

MarioRe's avatar
MarioRe
New Contributor
5 years ago

Swagger Core 2.x OpeanAPI 3 Examples tied to Dataclass(variables)

I'd like to to add examples to my OpenAPI 3 Autogenerated Documentation which I generate with "io.swagger.core.v3.swagger-gradle-plugin"

I didn't find a way to bind the example to the variable of my dataclass, like you could do with @ApiModelProperty for a swagger V2 file.

All I found is @ExampleObject which you have to define for each response as a String. Am I missing something or is that the only way to add Examples to a swagger.v3 approach?

1 Reply

  • MarioRe's avatar
    MarioRe
    New Contributor

    I found it out myself, you need the @Schema annotation and not the @Parameter annotation, moreover it ignores the variables and only uses the Getter and Setter to generate the YAML.