I am using The openapi-generator-maven-plugin:6.4.0 to generate swagger code. I am able to access the APIs.
But, in generated files @ExampleObject is not present. Also, in Swagger UI I am unable to see the examples specified in inputSpec. Please suggest.
Below are the dependencies and plugins used in pom.xml file
Dependencies:
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-ui</artifactId>
<version>1.6.14</version>
</dependency>
<dependency>
<groupId>org.openapitools</groupId>
<artifactId>jackson-databind-nullable</artifactId>
<version>0.2.1</version>
</dependency>
Plugin:
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>6.4.0</version>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>/src/main/resources/openapi.json</inputSpec>
<apiPackage>com.example.api</apiPackage>
<modelPackage>com.example.model</modelPackage>
<skipOperationExample>false</skipOperaionExample> <generatorName>spring</generatorName>
<configOptions> <sourceFolder>src/gen/java/main</sourceFolder<delegatePattern>true</delegatePattern>
<interfaceOnly>true</interfaceOnly>
</configOptions>
</configuration>
</execution>
</executions>
</plugin>
openapi-generator
doesn't create@ExampleObject
annotations. You can verify this by checking themustache
templates used to generate the objects. It sets the example using the@schema
annotation instead. As for the examples not showing up in the ui, I can't help you without being able to see the input spec. Can you please share your input spec and your maven configuration? Thank you. – Abrupt