Skip to content

Commit 6edf9b9

Browse files
authored
Merge branch 'master' into issue1086
2 parents ebfd7f0 + 895c99f commit 6edf9b9

File tree

9 files changed

+155
-23
lines changed

9 files changed

+155
-23
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ You can include this library from Sonatype OSS for SNAPSHOTS, or Maven central f
103103
<dependency>
104104
<groupId>io.swagger.parser.v3</groupId>
105105
<artifactId>swagger-parser</artifactId>
106-
<version>2.0.12</version>
106+
<version>2.0.13</version>
107107
</dependency>
108108
```
109109

modules/swagger-parser-core/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<parent>
44
<groupId>io.swagger.parser.v3</groupId>
55
<artifactId>swagger-parser-project</artifactId>
6-
<version>2.0.13-SNAPSHOT</version>
6+
<version>2.0.14-SNAPSHOT</version>
77
<relativePath>../..</relativePath>
88
</parent>
99
<modelVersion>4.0.0</modelVersion>

modules/swagger-parser-v2-converter/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<parent>
44
<groupId>io.swagger.parser.v3</groupId>
55
<artifactId>swagger-parser-project</artifactId>
6-
<version>2.0.13-SNAPSHOT</version>
6+
<version>2.0.14-SNAPSHOT</version>
77
<relativePath>../..</relativePath>
88
</parent>
99
<modelVersion>4.0.0</modelVersion>

modules/swagger-parser-v3/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<parent>
44
<groupId>io.swagger.parser.v3</groupId>
55
<artifactId>swagger-parser-project</artifactId>
6-
<version>2.0.13-SNAPSHOT</version>
6+
<version>2.0.14-SNAPSHOT</version>
77
<relativePath>../..</relativePath>
88
</parent>
99
<modelVersion>4.0.0</modelVersion>

modules/swagger-parser-v3/src/main/java/io/swagger/v3/parser/OpenAPIV3Parser.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import org.slf4j.LoggerFactory;
1919

2020
import java.net.URI;
21+
import java.nio.charset.Charset;
2122
import java.nio.file.Files;
2223
import java.nio.file.Path;
2324
import java.nio.file.Paths;
@@ -30,11 +31,23 @@
3031
public class OpenAPIV3Parser implements SwaggerParserExtension {
3132
private static ObjectMapper JSON_MAPPER, YAML_MAPPER;
3233
private static final Logger LOGGER = LoggerFactory.getLogger(OpenAPIV3Parser.class);
34+
private static String encoding = "UTF-8";
3335

3436
static {
3537
JSON_MAPPER = ObjectMapperFactory.createJson();
3638
YAML_MAPPER = ObjectMapperFactory.createYaml();
3739
}
40+
41+
public static String getEncoding() {
42+
return encoding;
43+
}
44+
45+
public static void setEncoding(String encoding) {
46+
if (Charset.isSupported(encoding)) {
47+
OpenAPIV3Parser.encoding = encoding;
48+
}
49+
}
50+
3851
@Override
3952
public SwaggerParseResult readLocation(String url, List<AuthorizationValue> auth, ParseOptions options) {
4053
SwaggerParseResult result = new SwaggerParseResult();
@@ -130,7 +143,7 @@ public SwaggerParseResult readWithInfo(String location, List<AuthorizationValue>
130143
path = Paths.get(location);
131144
}
132145
if (Files.exists(path)) {
133-
data = FileUtils.readFileToString(path.toFile(), "UTF-8");
146+
data = FileUtils.readFileToString(path.toFile(), encoding);
134147
} else {
135148
data = ClasspathHelper.loadFileFromClasspath(location);
136149
}

modules/swagger-parser-v3/src/test/java/io/swagger/v3/parser/test/OpenAPIV3ParserTest.java

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,29 @@ public class OpenAPIV3ParserTest {
6767
protected WireMockServer wireMockServer;
6868

6969

70+
71+
@Test
72+
public void testIssue339() throws Exception {
73+
OpenAPIV3Parser openAPIV3Parser = new OpenAPIV3Parser();
74+
OpenAPI api = openAPIV3Parser.read("issue-339.yaml");
75+
assertNotNull(api);
76+
Parameter param = api.getPaths().get("/store/order/{orderId}").getGet().getParameters().get(0);
77+
assertTrue(param instanceof PathParameter);
78+
PathParameter pp = (PathParameter) param;
79+
assertTrue(pp.getSchema().getMinimum().toString().equals("1"));
80+
assertTrue(pp.getSchema().getMaximum().toString().equals("5"));
81+
}
82+
83+
@Test
84+
public void testIssue1119() {
85+
OpenAPIV3Parser parser = new OpenAPIV3Parser();
86+
parser.setEncoding("ISO-8859-1");
87+
OpenAPI openAPI = parser.read("src/test/resources/issue-1119.yaml");
88+
assertNotNull(openAPI);
89+
assertEquals(openAPI.getPaths().get("/pets").getGet().getParameters().get(0).getDescription(),"Cuántos artículos devolver al mismo tiempo (máximo 100)");
90+
}
91+
92+
7093
@Test
7194
public void testIssue1108() {
7295
OpenAPIV3Parser parser = new OpenAPIV3Parser();
@@ -1337,19 +1360,6 @@ public void testCodegenPetstore() {
13371360
assertEquals(minimum.toString(), "1");
13381361
}
13391362

1340-
@Test
1341-
public void testIssue339() throws Exception {
1342-
OpenAPIV3Parser parser = new OpenAPIV3Parser();
1343-
final OpenAPI openAPI = parser.read("src/test/resources/issue-339.yaml");
1344-
1345-
Parameter param = openAPI.getPaths().get("/store/order/{orderId}").getGet().getParameters().get(0);
1346-
assertTrue(param instanceof PathParameter);
1347-
PathParameter pp = (PathParameter) param;
1348-
1349-
assertTrue(pp.getSchema().getMinimum().toString().equals("1"));
1350-
assertTrue(pp.getSchema().getMaximum().toString().equals("5"));
1351-
}
1352-
13531363
@Test
13541364
public void testCodegenIssue4555() throws Exception {
13551365
OpenAPIV3Parser parser = new OpenAPIV3Parser();
Lines changed: 109 additions & 0 deletions
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: Listado de todas las
13+
operationId: listPets
14+
tags:
15+
- pets
16+
parameters:
17+
- name: limit
18+
in: query
19+
description: Cuántos artículos devolver al mismo tiempo (máximo 100)
20+
required: false
21+
schema:
22+
type: integer
23+
format: int32
24+
responses:
25+
'200':
26+
description: Una colección paginada de mascotas
27+
headers:
28+
x-next:
29+
description: Un enlace a la siguiente página de respuestas.
30+
schema:
31+
type: string
32+
content:
33+
application/json:
34+
schema:
35+
$ref: "#/components/schemas/Pets"
36+
default:
37+
description: Error inesperado
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: respuesta Null
50+
default:
51+
description: Error inesperado
52+
content:
53+
application/json:
54+
schema:
55+
$ref: "#/components/schemas/Error"
56+
/pets/{petId}:
57+
get:
58+
summary: Información para una mascota específica
59+
operationId: showPetById
60+
tags:
61+
- pets
62+
parameters:
63+
- name: petId
64+
in: path
65+
required: true
66+
description: El id de la mascota a recuperar.
67+
schema:
68+
type: string
69+
responses:
70+
'200':
71+
description: Respuesta esperada a una solicitud válida
72+
content:
73+
application/json:
74+
schema:
75+
$ref: "#/components/schemas/Pets"
76+
default:
77+
description: error inesperado
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

modules/swagger-parser/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<parent>
44
<groupId>io.swagger.parser.v3</groupId>
55
<artifactId>swagger-parser-project</artifactId>
6-
<version>2.0.13-SNAPSHOT</version>
6+
<version>2.0.14-SNAPSHOT</version>
77
<relativePath>../..</relativePath>
88
</parent>
99
<modelVersion>4.0.0</modelVersion>

pom.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<modelVersion>4.0.0</modelVersion>
99
<groupId>io.swagger.parser.v3</groupId>
1010
<artifactId>swagger-parser-project</artifactId>
11-
<version>2.0.13-SNAPSHOT</version>
11+
<version>2.0.14-SNAPSHOT</version>
1212
<packaging>pom</packaging>
1313
<name>swagger-parser-project</name>
1414
<developers>
@@ -285,17 +285,17 @@
285285
</repository>
286286
</repositories>
287287
<properties>
288-
<swagger-parser-v2-version>1.0.44</swagger-parser-v2-version>
288+
<swagger-parser-v2-version>1.0.46-SNAPSHOT</swagger-parser-v2-version>
289289
<commons-io-version>2.4</commons-io-version>
290290
<slf4j-version>1.6.3</slf4j-version>
291-
<swagger-core-version>2.0.8</swagger-core-version>
291+
<swagger-core-version>2.0.9-SNAPSHOT</swagger-core-version>
292292
<junit-version>4.8.1</junit-version>
293293
<testng-version>6.14.2</testng-version>
294294
<jmockit-version>1.35</jmockit-version>
295295
<wiremock-version>2.15.0</wiremock-version>
296296
<surefire-version>2.21.0</surefire-version>
297297
<commons-lang-version>3.2.1</commons-lang-version>
298-
<jackson-version>2.9.8</jackson-version>
298+
<jackson-version>2.9.9</jackson-version>
299299
</properties>
300300

301301
</project>

0 commit comments

Comments
 (0)