How to annotate a field as deprecated in OpenAPI (Swagger) 2.0?
37,161
Solution 1
The possibility to mark schemas and schema properties as deprecated
was added in OpenAPI 3.0:
openapi: 3.0.1
...
components:
schemas:
Service:
type: object
properties:
location:
type: string
description: Location of the service
example: '400 Street name, City State postcode, Country'
deprecated: true # <---------
If you use OpenAPI 2.0 (Swagger 2.0), the only thing you can do is document the deprecation verbally in the property description
.
Solution 2
according to documentation it is enough to use deprecated
attribute
/pet/findByTags:
get:
deprecated: true
Author by
saeedj
Updated on July 29, 2022Comments
-
saeedj almost 2 years
I have the following schema definition:
swagger: '2.0' ... definitions: Service: type: object properties: serviceId: type: string description: Device or service identification number example: 1111111111 location: type: string description: Location of the service example: '400 Street name, City State postcode, Country'
I would like to do annotate the
location
field as deprecated. Is there a way to do this? -
Samoht over 5 yearsHe asked for "ttribute", not the endpoint. @Helen has a correct anwer: not possible in OpenAPI 2.0
-
tharkay over 2 years@Samoht while you're correct that this doesn't answer the question, Google will show this as the top result for "swagger service deprecated"