We are implemented spring fox swagger 2 of version 2.6.1, i wanted to display a specific property of a resource for HTTP GET METHOD and not for POST METHOD, i haven't find any approach using swagger 2. Please help thanks.
For example:
Class Employee{
Integer id;
String name;
}
Request URI: GET /api/employee/{id} i should see the swagger request document as
{
id:"",
name:""
}
Request URI: POST /api/employee i should see the swagger request sample as
{
name:""
}
Using @JsonIgnore We can use it to specify that a field is to be ignored by Jackson during serialization and deserialization. We can add the annotation to just the field to be ignored, and it'll hide both getters and setters for the specified field.
A single path can support multiple operations, for example GET /users to get a list of users and POST /users to add a new user.
There is no special attribute which can mark service endpoint to show it as deprecated in swagger schema, but you can use OperationFilter action when register SwaggerFeature to modify swagger declarations and set Deprecated property to string “true” for obsolete methods.
To hide the "Models" section, add defaultModelsExpandDepth: -1 to the Swagger UI configuration code in your index.
I upgraded to version 2.8.0 and it is possible with @ApiModelProperty(readOnly = true). This causes the property to be #Returned by GET, not used in POST / PUT / PATCH
This was the valid response in older swagger.
@ApiModelProperty(readOnly = true)
In Swagger V3 you need to use AccesMode. Example:
@Schema(accessMode = Schema.AccessMode.READ_ONLY)
private long id;
This will make id visible for all GET requests.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With