Swagger 招摇过市

Swagger 招摇过市,swagger,jax-rs,swagger-2.0,swagger-codegen,swagger-editor,Swagger,Jax Rs,Swagger 2.0,Swagger Codegen,Swagger Editor,我试图用一个json主体的示例来记录一个api错误响应。我找不到示例或合适的注释。与招摇过市的编辑一起玩,我至少可以得到一些看起来像我想要达到的结果 responses: '200' : description: Request completed with no errors examples: application/json: {"result" : { "id": "blue" }} 正在使用的库是swagger core 1.6

我试图用一个json主体的示例来记录一个api错误响应。我找不到示例或合适的注释。与招摇过市的编辑一起玩,我至少可以得到一些看起来像我想要达到的结果

responses:
    '200' :
      description: Request completed with no errors
      examples:   
        application/json:  {"result" : { "id": "blue" }}
正在使用的库是swagger core 1.6.0

 <dependency>
            <groupId>io.swagger</groupId>
            <artifactId>swagger-core</artifactId>
            <scope>compile</scope>
            <version>1.6.0</version>
</dependency>
生成的swagger.json没有所需的

examples:   
 application/json:  {"result" : { "id": "blue" }}         
我还尝试传递response=ApiResponse.class、Examples.class和Example.class,但没有改变


如何使用注释实现这一点

我认为您应该使用io.swagger.core.v3,因为这些注释与OpenAPI v3规范相关(swagger 2又称OpenAPI v2)。
examples:   
 application/json:  {"result" : { "id": "blue" }}