Skip to content

Commit 8c4ddf7

Browse files
committed
Merge branch 'pr-54' into pr-70
2 parents 7734db0 + 7eb3317 commit 8c4ddf7

File tree

4 files changed

+238
-2
lines changed

4 files changed

+238
-2
lines changed

pom.xml

+8-2
Original file line numberDiff line numberDiff line change
@@ -57,18 +57,24 @@
5757
<junit.jupiter.version>5.6.2</junit.jupiter.version>
5858
<junit.platform.version>1.3.2</junit.platform.version>
5959
<assertj-core.version>3.15.0</assertj-core.version>
60+
<swagger-parser.version>2.0.17</swagger-parser.version>
6061
</properties>
6162

6263
<dependencies>
6364
<dependency>
6465
<groupId>io.swagger.parser.v3</groupId>
6566
<artifactId>swagger-parser-v3</artifactId>
66-
<version>2.0.17</version>
67+
<version>${swagger-parser.version}</version>
6768
</dependency>
6869
<dependency>
6970
<groupId>io.swagger.parser.v3</groupId>
7071
<artifactId>swagger-parser</artifactId>
71-
<version>2.0.17</version>
72+
<version>${swagger-parser.version}</version>
73+
</dependency>
74+
<dependency>
75+
<groupId>io.swagger.parser.v3</groupId>
76+
<artifactId>swagger-parser-v2-converter</artifactId>
77+
<version>${swagger-parser.version}</version>
7278
</dependency>
7379
<dependency>
7480
<groupId>com.j2html</groupId>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package com.qdesrame.openapi.test;
2+
3+
import org.junit.Test;
4+
5+
import static com.qdesrame.openapi.test.TestUtils.assertOpenApiAreEquals;
6+
7+
public class Swagger2CompatibilityTest {
8+
private final String SWAGGER_DOC1 = "petstore_swagger2.yaml";
9+
private final String OPENAPI_DOC2 = "petstore_openapi3.yaml";
10+
11+
@Test
12+
public void testEqual() {
13+
assertOpenApiAreEquals(SWAGGER_DOC1, SWAGGER_DOC1);
14+
}
15+
16+
@Test
17+
public void testSwagger2ToOpenapi3() {
18+
assertOpenApiAreEquals(SWAGGER_DOC1, OPENAPI_DOC2);
19+
}
20+
}
+109
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
openapi: "3.0.0"
2+
info:
3+
version: 1.0.0
4+
title: Swagger Petstore
5+
license:
6+
name: MIT
7+
servers:
8+
- url: http://petstore.swagger.io/v1
9+
paths:
10+
/pets:
11+
get:
12+
summary: List all pets
13+
operationId: listPets
14+
tags:
15+
- pets
16+
parameters:
17+
- name: limit
18+
in: query
19+
description: How many items to return at one time (max 100)
20+
required: false
21+
schema:
22+
type: integer
23+
format: int32
24+
responses:
25+
'200':
26+
description: A paged array of pets
27+
headers:
28+
x-next:
29+
description: A link to the next page of responses
30+
schema:
31+
type: string
32+
content:
33+
application/json:
34+
schema:
35+
$ref: "#/components/schemas/Pets"
36+
default:
37+
description: unexpected error
38+
content:
39+
application/json:
40+
schema:
41+
$ref: "#/components/schemas/Error"
42+
post:
43+
summary: Create a pet
44+
operationId: createPets
45+
tags:
46+
- pets
47+
responses:
48+
'201':
49+
description: Null response
50+
default:
51+
description: unexpected error
52+
content:
53+
application/json:
54+
schema:
55+
$ref: "#/components/schemas/Error"
56+
/pets/{petId}:
57+
get:
58+
summary: Info for a specific pet
59+
operationId: showPetById
60+
tags:
61+
- pets
62+
parameters:
63+
- name: petId
64+
in: path
65+
required: true
66+
description: The id of the pet to retrieve
67+
schema:
68+
type: string
69+
responses:
70+
'200':
71+
description: Expected response to a valid request
72+
content:
73+
application/json:
74+
schema:
75+
$ref: "#/components/schemas/Pets"
76+
default:
77+
description: unexpected error
78+
content:
79+
application/json:
80+
schema:
81+
$ref: "#/components/schemas/Error"
82+
components:
83+
schemas:
84+
Pet:
85+
required:
86+
- id
87+
- name
88+
properties:
89+
id:
90+
type: integer
91+
format: int64
92+
name:
93+
type: string
94+
tag:
95+
type: string
96+
Pets:
97+
type: array
98+
items:
99+
$ref: "#/components/schemas/Pet"
100+
Error:
101+
required:
102+
- code
103+
- message
104+
properties:
105+
code:
106+
type: integer
107+
format: int32
108+
message:
109+
type: string
+101
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
swagger: "2.0"
2+
info:
3+
version: 1.0.0
4+
title: Swagger Petstore
5+
license:
6+
name: MIT
7+
host: petstore.swagger.io
8+
basePath: /v1
9+
schemes:
10+
- http
11+
consumes:
12+
- application/json
13+
produces:
14+
- application/json
15+
paths:
16+
/pets:
17+
get:
18+
summary: List all pets
19+
operationId: listPets
20+
tags:
21+
- pets
22+
parameters:
23+
- name: limit
24+
in: query
25+
description: How many items to return at one time (max 100)
26+
required: false
27+
type: integer
28+
format: int32
29+
responses:
30+
"200":
31+
description: A paged array of pets
32+
headers:
33+
x-next:
34+
type: string
35+
description: A link to the next page of responses
36+
schema:
37+
$ref: '#/definitions/Pets'
38+
default:
39+
description: unexpected error
40+
schema:
41+
$ref: '#/definitions/Error'
42+
post:
43+
summary: Create a pet
44+
operationId: createPets
45+
tags:
46+
- pets
47+
responses:
48+
"201":
49+
description: Null response
50+
default:
51+
description: unexpected error
52+
schema:
53+
$ref: '#/definitions/Error'
54+
/pets/{petId}:
55+
get:
56+
summary: Info for a specific pet
57+
operationId: showPetById
58+
tags:
59+
- pets
60+
parameters:
61+
- name: petId
62+
in: path
63+
required: true
64+
description: The id of the pet to retrieve
65+
type: string
66+
responses:
67+
"200":
68+
description: Expected response to a valid request
69+
schema:
70+
$ref: '#/definitions/Pets'
71+
default:
72+
description: unexpected error
73+
schema:
74+
$ref: '#/definitions/Error'
75+
definitions:
76+
Pet:
77+
required:
78+
- id
79+
- name
80+
properties:
81+
id:
82+
type: integer
83+
format: int64
84+
name:
85+
type: string
86+
tag:
87+
type: string
88+
Pets:
89+
type: array
90+
items:
91+
$ref: '#/definitions/Pet'
92+
Error:
93+
required:
94+
- code
95+
- message
96+
properties:
97+
code:
98+
type: integer
99+
format: int32
100+
message:
101+
type: string

0 commit comments

Comments
 (0)