Skip to content

Commit c6b0977

Browse files
authored
Merge branch 'master' into fix-triple-slash-url
2 parents 34679de + e6b3f65 commit c6b0977

File tree

5 files changed

+62
-2
lines changed

5 files changed

+62
-2
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,9 @@ You can include this library from Sonatype OSS for SNAPSHOTS, or Maven central f
103103
</dependency>
104104
```
105105

106+
## Security contact
107+
108+
Please disclose any security-related issues or vulnerabilities by emailing [[email protected]](mailto:[email protected]), instead of using the public issue tracker.
106109

107110
License
108111
-------

modules/swagger-parser-v3/src/main/java/io/swagger/v3/parser/util/DeserializationUtils.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.fasterxml.jackson.databind.JsonNode;
44
import io.swagger.v3.core.util.Yaml;
55
import io.swagger.v3.core.util.Json;
6+
import org.yaml.snakeyaml.constructor.SafeConstructor;
67

78
import java.io.IOException;
89

@@ -57,12 +58,12 @@ private static boolean isJson(String contents) {
5758
}
5859

5960
public static JsonNode readYamlTree(String contents) {
60-
org.yaml.snakeyaml.Yaml yaml = new org.yaml.snakeyaml.Yaml();
61+
org.yaml.snakeyaml.Yaml yaml = new org.yaml.snakeyaml.Yaml(new SafeConstructor());
6162
return Json.mapper().convertValue(yaml.load(contents), JsonNode.class);
6263
}
6364

6465
public static <T> T readYamlValue(String contents, Class<T> expectedType) {
65-
org.yaml.snakeyaml.Yaml yaml = new org.yaml.snakeyaml.Yaml();
66+
org.yaml.snakeyaml.Yaml yaml = new org.yaml.snakeyaml.Yaml(new SafeConstructor());
6667
return Json.mapper().convertValue(yaml.load(contents), expectedType);
6768
}
6869
}

modules/swagger-parser-v3/src/main/java/io/swagger/v3/parser/util/ResolverFully.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import io.swagger.v3.oas.models.links.Link;
1212
import io.swagger.v3.oas.models.media.ArraySchema;
1313
import io.swagger.v3.oas.models.media.ComposedSchema;
14+
import io.swagger.v3.oas.models.media.MapSchema;
1415
import io.swagger.v3.oas.models.media.MediaType;
1516
import io.swagger.v3.oas.models.media.ObjectSchema;
1617
import io.swagger.v3.oas.models.media.Schema;
@@ -307,6 +308,15 @@ public Schema resolveSchema(Schema schema) {
307308

308309
return arrayModel;
309310
}
311+
312+
if (schema instanceof MapSchema) {
313+
MapSchema mapSchema = (MapSchema) schema;
314+
if (mapSchema.getAdditionalProperties() instanceof Schema) {
315+
Schema additionalPropertiesSchema = (Schema) mapSchema.getAdditionalProperties();
316+
mapSchema.setAdditionalProperties(resolveSchema(additionalPropertiesSchema));
317+
}
318+
}
319+
310320
if (schema instanceof ObjectSchema) {
311321
ObjectSchema obj = (ObjectSchema) schema;
312322
if(obj.getProperties() != null) {

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1931,6 +1931,21 @@ public void testIssue1063() {
19311931

19321932
}
19331933

1934+
@Test
1935+
public void testResolveFullyMap() {
1936+
ParseOptions options = new ParseOptions();
1937+
options.setResolveFully(false);
1938+
OpenAPI openAPI = new OpenAPIV3Parser().readLocation("resolve-fully-map.yaml", null, options).getOpenAPI();
1939+
String yaml = Yaml.pretty(openAPI);
1940+
assertTrue(yaml.contains("$ref"));
1941+
1942+
options = new ParseOptions();
1943+
options.setResolveFully(true);
1944+
openAPI = new OpenAPIV3Parser().readLocation("resolve-fully-map.yaml", null, options).getOpenAPI();
1945+
yaml = Yaml.pretty(openAPI);
1946+
assertFalse(yaml.contains("$ref"));
1947+
}
1948+
19341949
private static int getDynamicPort() {
19351950
return new Random().ints(10000, 20000).findFirst().getAsInt();
19361951
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
openapi: 3.0.0
2+
servers:
3+
- url: 'http://localhost:8080/sample'
4+
info:
5+
description: A simple API to learn how to write OpenAPI Specification
6+
version: 1.0.1
7+
title: Simple API
8+
paths:
9+
/sample:
10+
get:
11+
tags:
12+
- Sample
13+
operationId: getSample
14+
responses:
15+
'200':
16+
description: Sample
17+
content:
18+
application/json:
19+
schema:
20+
$ref: '#/components/schemas/MyModelMap'
21+
components:
22+
schemas:
23+
MyModel:
24+
type: object
25+
properties:
26+
name:
27+
type: string
28+
MyModelMap:
29+
type: object
30+
additionalProperties:
31+
$ref: "#/components/schemas/MyModel"

0 commit comments

Comments
 (0)