In this blog, we will compare the differences between OAS 2.0 and OAS 3.0
- Host, base path and schemes are replaced with Servers.
- OAS 2.0
host: dev.example.combasePath: /v1schemes:- https- http
- OAS 3.0
servers:- url: https://dev.example.com/v1- url: http://dev.example.com/v1
- Instead of consumes and produces, keyword content will be used
- Content allows wildcard media types. For example, image/* represents all image types
- 4 type of parameters are available now - query, path, header and cookie(new)
- Instead of securityDefinitions, new keyword is securitySchemes under components
- For Basic Authentication, type: basic was replaced with type: http and scheme: basic
- CommonMark will be used for descriptions instead of MarkDown
- type should be put under schema
- OAS 2.0
parameters:- in: pathname: meme-idrequired: truetype: integer
- OAS 3.0
parameters:- name: qin: queryschema:type: stringformat: byte
- It uses semantic versioning (MAJOR.MINOR.PATCH)
- OAS 2.0
swagger: "2.0"
- OAS 3.0
openapi: 3.0.1
- Body and form parameters are replaced with requestBody
- OAS 2.0
paths:/dummy:post:description: sampleconsumes:- image/jpeg- image/gifproduces:- application/xmlparameters:- in: formDataname: inputFilerequired: truetype: file- in: queryname: captiontype: stringresponses:200:description: successfulschema:type: file
- OAS3.0
/dummy:post:description: sampleparameters:- name: captionin: queryschema:type: stringrequestBody:content:image/jpeg:schema:required:- inputFileproperties:inputFile:type: stringformat: binaryimage/gif:schema:required:- inputFileproperties:inputFile:type: stringformat: binaryrequired: trueresponses:200:description: successfulcontent:application/xml:schema:type: stringformat: binary
- The global components/schemas will be used for common data structures
- OAS 2.0
$ref: "#/definitions/Meme"
- OAS 3.0
$ref: '#/components/schemas/Meme'
No comments:
Post a Comment