diff --git a/pom.xml b/pom.xml
index b55c480a6..a3d86756c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -53,13 +53,19 @@
UTF-8
github
+ 2.0.1
io.swagger.parser.v3
swagger-parser-v3
- 2.0.1
+ ${swagger-parser.version}
+
+
+ io.swagger.parser.v3
+ swagger-parser-v2-converter
+ ${swagger-parser.version}
com.j2html
diff --git a/src/test/java/com/qdesrame/openapi/test/Swagger2CompatibilityTest.java b/src/test/java/com/qdesrame/openapi/test/Swagger2CompatibilityTest.java
new file mode 100644
index 000000000..d16861495
--- /dev/null
+++ b/src/test/java/com/qdesrame/openapi/test/Swagger2CompatibilityTest.java
@@ -0,0 +1,20 @@
+package com.qdesrame.openapi.test;
+
+import org.junit.Test;
+
+import static com.qdesrame.openapi.test.TestUtils.assertOpenApiAreEquals;
+
+public class Swagger2CompatibilityTest {
+ private final String SWAGGER_DOC1 = "petstore_swagger2.yaml";
+ private final String OPENAPI_DOC2 = "petstore_openapi3.yaml";
+
+ @Test
+ public void testEqual() {
+ assertOpenApiAreEquals(SWAGGER_DOC1, SWAGGER_DOC1);
+ }
+
+ @Test
+ public void testSwagger2ToOpenapi3() {
+ assertOpenApiAreEquals(SWAGGER_DOC1, OPENAPI_DOC2);
+ }
+}
diff --git a/src/test/resources/petstore_openapi3.yaml b/src/test/resources/petstore_openapi3.yaml
new file mode 100644
index 000000000..264dbeabf
--- /dev/null
+++ b/src/test/resources/petstore_openapi3.yaml
@@ -0,0 +1,109 @@
+openapi: "3.0.0"
+info:
+ version: 1.0.0
+ title: Swagger Petstore
+ license:
+ name: MIT
+servers:
+ - url: http://petstore.swagger.io/v1
+paths:
+ /pets:
+ get:
+ summary: List all pets
+ operationId: listPets
+ tags:
+ - pets
+ parameters:
+ - name: limit
+ in: query
+ description: How many items to return at one time (max 100)
+ required: false
+ schema:
+ type: integer
+ format: int32
+ responses:
+ '200':
+ description: A paged array of pets
+ headers:
+ x-next:
+ description: A link to the next page of responses
+ schema:
+ type: string
+ content:
+ application/json:
+ schema:
+ $ref: "#/components/schemas/Pets"
+ default:
+ description: unexpected error
+ content:
+ application/json:
+ schema:
+ $ref: "#/components/schemas/Error"
+ post:
+ summary: Create a pet
+ operationId: createPets
+ tags:
+ - pets
+ responses:
+ '201':
+ description: Null response
+ default:
+ description: unexpected error
+ content:
+ application/json:
+ schema:
+ $ref: "#/components/schemas/Error"
+ /pets/{petId}:
+ get:
+ summary: Info for a specific pet
+ operationId: showPetById
+ tags:
+ - pets
+ parameters:
+ - name: petId
+ in: path
+ required: true
+ description: The id of the pet to retrieve
+ schema:
+ type: string
+ responses:
+ '200':
+ description: Expected response to a valid request
+ content:
+ application/json:
+ schema:
+ $ref: "#/components/schemas/Pets"
+ default:
+ description: unexpected error
+ content:
+ application/json:
+ schema:
+ $ref: "#/components/schemas/Error"
+components:
+ schemas:
+ Pet:
+ required:
+ - id
+ - name
+ properties:
+ id:
+ type: integer
+ format: int64
+ name:
+ type: string
+ tag:
+ type: string
+ Pets:
+ type: array
+ items:
+ $ref: "#/components/schemas/Pet"
+ Error:
+ required:
+ - code
+ - message
+ properties:
+ code:
+ type: integer
+ format: int32
+ message:
+ type: string
diff --git a/src/test/resources/petstore_swagger2.yaml b/src/test/resources/petstore_swagger2.yaml
new file mode 100644
index 000000000..ecd195aa6
--- /dev/null
+++ b/src/test/resources/petstore_swagger2.yaml
@@ -0,0 +1,101 @@
+swagger: "2.0"
+info:
+ version: 1.0.0
+ title: Swagger Petstore
+ license:
+ name: MIT
+host: petstore.swagger.io
+basePath: /v1
+schemes:
+ - http
+consumes:
+ - application/json
+produces:
+ - application/json
+paths:
+ /pets:
+ get:
+ summary: List all pets
+ operationId: listPets
+ tags:
+ - pets
+ parameters:
+ - name: limit
+ in: query
+ description: How many items to return at one time (max 100)
+ required: false
+ type: integer
+ format: int32
+ responses:
+ "200":
+ description: A paged array of pets
+ headers:
+ x-next:
+ type: string
+ description: A link to the next page of responses
+ schema:
+ $ref: '#/definitions/Pets'
+ default:
+ description: unexpected error
+ schema:
+ $ref: '#/definitions/Error'
+ post:
+ summary: Create a pet
+ operationId: createPets
+ tags:
+ - pets
+ responses:
+ "201":
+ description: Null response
+ default:
+ description: unexpected error
+ schema:
+ $ref: '#/definitions/Error'
+ /pets/{petId}:
+ get:
+ summary: Info for a specific pet
+ operationId: showPetById
+ tags:
+ - pets
+ parameters:
+ - name: petId
+ in: path
+ required: true
+ description: The id of the pet to retrieve
+ type: string
+ responses:
+ "200":
+ description: Expected response to a valid request
+ schema:
+ $ref: '#/definitions/Pets'
+ default:
+ description: unexpected error
+ schema:
+ $ref: '#/definitions/Error'
+definitions:
+ Pet:
+ required:
+ - id
+ - name
+ properties:
+ id:
+ type: integer
+ format: int64
+ name:
+ type: string
+ tag:
+ type: string
+ Pets:
+ type: array
+ items:
+ $ref: '#/definitions/Pet'
+ Error:
+ required:
+ - code
+ - message
+ properties:
+ code:
+ type: integer
+ format: int32
+ message:
+ type: string
\ No newline at end of file