how to use @Example。Why I use @Example no effect

i copy this code in https://github.com/swagger-api/swagger-core/blob/master/modules/swagger-jaxrs/src/test/java/io/swagger/resources/ClassWithExamplePost.java but no effect

@rim-wood can you share the swagger.json you're getting?
@webron this is part of my swagger.json
"/surviveevent/external/info": { "post": { "tags": [ "surviveevent" ], "summary": "test", "description": "", "operationId": "postTest", "consumes": [ "application/json" ], "produces": [ "application/json" ], "parameters": [ { "in": "body", "name": "test", "description": "test", "required": false, "schema": { "type": "array", "items": { "type": "string" } }, "x-examples": { "application/json": "["a","b"]" } } ], "responses": { "default": { "description": "successful operation" } } } },
and x-examples is exist,but swagger-ui is not show.
otherwise,use @ApiImplicitParam, for example,@ApiImplicitParam(name="id",value="幸免事件id",dataType = "String").the swagger.json does not exist description in parameters
Right. The current version of swagger-ui doesn't support the x-example/s extensions. It should work if you provide the example through the model itself.
@webron
yes,if i provide the example through the model,this is work.
but you know,
The add and modified is different,add method may be need more param.
if i use @ApiModelProperty , That means add and modified show the some param in swagger-ui.
for example,
the model hava 4 param in add method,and is required in addition to facilityCode.
but in edit method, facilityCode is required,the other is not.
I do not know whether you understand what I mean,if you hava solution,please tell me
Yeah, I understand. However, when it comes to Swagger, there's no simple solution to it because of how JSON Schema works. Effectively you'd need to create two different classes where in one the field is required and in the other it is not. Those classes can of course inherit from each other.
@webron ok,i see, thank you very much
@webron I meet the same issue. I don't want to show the model schema because of to large. I try to use @example annotation but not work.
swagger-jersey2-jaxrs:1.5.16
swaggerUI:3.3.2
swagger.json generated by annotation:
code:
public Response registerApp(@HeaderParam("X-Auth-Token")String token, @PathParam("registeredSystem") RegisteredSystem registeredSystem,
@ApiParam(value = "request",
examples = @Example(value = {
@ExampleProperty(mediaType="application/json", value="[\"a\",\"b\"]")
})) ApplicationRegistrationCreateRequest request) {...}
请问下有什么解决方案没有
Would you please tell me what the solution under no