Ask a Question

Swagger API specs - customize API response property usign @ApiPropertyModel

swathi1
Visitor

Swagger API specs - customize API response property usign @ApiPropertyModel

<dependencies>
  <dependency>
    <groupId>io.swagger</groupId>
    <artifactId>swagger-core</artifactId>
    <version>1.5.1</version>
  </dependency>
</dependencies>
<build>
    <plugins>
        <plugin>
            <groupId>com.github.kongchen</groupId>
            <artifactId>swagger-maven-plugin</artifactId>
            <version>3.1.8</version>
            <configuration>
                <apiSources>
                    <apiSource>
                        ...
                    </apiSource>
                </apiSources>
            </configuration>
            <executions>
                <execution>
                    <phase>compile</phase>
                    <goals>
                        <goal>generate</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>
---------------------------------

class ResponsePojo {
   ...
   @ApiModelProperty(name="metadata")
   private Map<String, Object> metadata;
   ...
}
-----------------------------------------------
Generated yaml file

definitions:
  ResponsePojo:
   type: object
   properties:
     metadata:
      type: object
      additionalProperties:
        type: object
---------------------------------------
Expected yaml file
definitions:
  ResponsePojo:
   type: object
   properties:
     metadata:
      type: object
      additionalProperties: {}
------------------------------------------

How to achieve this programmatically using ApiModelProperty ? Please advise.



cancel
Showing results for 
Search instead for 
Did you mean: