Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to annotate a field as deprecated in OpenAPI (Swagger) 2.0?

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?

like image 560
saeedj Avatar asked Apr 17 '18 04:04

saeedj


2 Answers

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.

like image 141
Helen Avatar answered Sep 28 '22 07:09

Helen


according to documentation it is enough to use deprecated attribute

/pet/findByTags: get:   deprecated: true 
like image 21
Tomas Avatar answered Sep 28 '22 05:09

Tomas