Skip to content

Commit

Permalink
CHORE[DEPENDENCIES]: bump swagger-parser => 2.0.22 (#7597)
Browse files Browse the repository at this point in the history
this fixes a bug where the parser would return
null when missing parameters rather than reporting
some useful error.

Fixes N/A
  • Loading branch information
codymikol authored Dec 8, 2020
1 parent 9e0badb commit f9d6c6f
Show file tree
Hide file tree
Showing 44 changed files with 64 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -472,14 +472,22 @@ private void flattenComponents(OpenAPI openAPI) {
* @param m Schema implementation
*/
private void fixStringModel(Schema m) {
if (m.getType() != null && m.getType().equals("string") && m.getExample() != null) {
if (schemaIsOfType(m, "string") && schemaContainsExample(m)) {
String example = m.getExample().toString();
if (example.substring(0, 1).equals("\"") && example.substring(example.length() - 1).equals("\"")) {
if (example.startsWith("\"") && example.endsWith("\"")) {
m.setExample(example.substring(1, example.length() - 1));
}
}
}

private boolean schemaIsOfType(Schema m, String type) {
return m.getType() != null && m.getType().equals(type);
}

private boolean schemaContainsExample(Schema m) {
return m.getExample() != null && m.getExample() != "";
}

/**
* Generates a unique model name. Non-alphanumeric characters will be replaced
* with underscores
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import io.swagger.v3.oas.models.responses.ApiResponses;
import io.swagger.v3.parser.core.models.ParseOptions;
import org.openapitools.codegen.utils.ModelUtils;
import org.testng.Assert;
import org.testng.annotations.Test;

import java.util.HashMap;
Expand Down Expand Up @@ -927,7 +928,7 @@ public void emptyExampleOnStringTypeModels() {
assertEquals("#/components/schemas/EmptyExampleOnStringTypeModels", schema.getItems().get$ref());

assertTrue(ModelUtils.getReferencedSchema(openAPI, schema.getItems()) instanceof StringSchema);
assertNull(ModelUtils.getReferencedSchema(openAPI, schema.getItems()).getExample());
Assert.assertSame(ModelUtils.getReferencedSchema(openAPI, schema.getItems()).getExample(), "");
}

@Test
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1516,7 +1516,7 @@
<maven.compiler.target>1.8</maven.compiler.target>
<swagger-core-version>2.1.2</swagger-core-version>
<swagger-parser-groupid>io.swagger.parser.v3</swagger-parser-groupid>
<swagger-parser-version>2.0.20</swagger-parser-version>
<swagger-parser-version>2.0.22</swagger-parser-version>
<felix-version>3.3.1</felix-version>
<commons-io-version>2.4</commons-io-version>
<commons-cli-version>1.2</commons-cli-version>
Expand Down
1 change: 1 addition & 0 deletions samples/client/petstore/go/go-petstore/api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2126,3 +2126,4 @@ components:
http_basic_test:
scheme: basic
type: http
x-original-swagger-version: "2.0"
1 change: 1 addition & 0 deletions samples/client/petstore/haskell-http-client/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2126,3 +2126,4 @@ components:
http_basic_test:
scheme: basic
type: http
x-original-swagger-version: "2.0"
Original file line number Diff line number Diff line change
Expand Up @@ -2187,4 +2187,5 @@ components:
http_basic_test:
scheme: basic
type: http
x-original-swagger-version: "2.0"

1 change: 1 addition & 0 deletions samples/client/petstore/java/feign/api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2187,4 +2187,5 @@ components:
http_basic_test:
scheme: basic
type: http
x-original-swagger-version: "2.0"

Original file line number Diff line number Diff line change
Expand Up @@ -2187,4 +2187,5 @@ components:
http_basic_test:
scheme: basic
type: http
x-original-swagger-version: "2.0"

1 change: 1 addition & 0 deletions samples/client/petstore/java/jersey1/api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2187,4 +2187,5 @@ components:
http_basic_test:
scheme: basic
type: http
x-original-swagger-version: "2.0"

Original file line number Diff line number Diff line change
Expand Up @@ -2187,4 +2187,5 @@ components:
http_basic_test:
scheme: basic
type: http
x-original-swagger-version: "2.0"

1 change: 1 addition & 0 deletions samples/client/petstore/java/native-async/api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2187,4 +2187,5 @@ components:
http_basic_test:
scheme: basic
type: http
x-original-swagger-version: "2.0"

1 change: 1 addition & 0 deletions samples/client/petstore/java/native/api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2187,4 +2187,5 @@ components:
http_basic_test:
scheme: basic
type: http
x-original-swagger-version: "2.0"

Original file line number Diff line number Diff line change
Expand Up @@ -2187,4 +2187,5 @@ components:
http_basic_test:
scheme: basic
type: http
x-original-swagger-version: "2.0"

1 change: 1 addition & 0 deletions samples/client/petstore/java/okhttp-gson/api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2187,4 +2187,5 @@ components:
http_basic_test:
scheme: basic
type: http
x-original-swagger-version: "2.0"

Original file line number Diff line number Diff line change
Expand Up @@ -2187,4 +2187,5 @@ components:
http_basic_test:
scheme: basic
type: http
x-original-swagger-version: "2.0"

1 change: 1 addition & 0 deletions samples/client/petstore/java/rest-assured/api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2187,4 +2187,5 @@ components:
http_basic_test:
scheme: basic
type: http
x-original-swagger-version: "2.0"

1 change: 1 addition & 0 deletions samples/client/petstore/java/resteasy/api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2187,4 +2187,5 @@ components:
http_basic_test:
scheme: basic
type: http
x-original-swagger-version: "2.0"

Original file line number Diff line number Diff line change
Expand Up @@ -2187,4 +2187,5 @@ components:
http_basic_test:
scheme: basic
type: http
x-original-swagger-version: "2.0"

1 change: 1 addition & 0 deletions samples/client/petstore/java/resttemplate/api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2187,4 +2187,5 @@ components:
http_basic_test:
scheme: basic
type: http
x-original-swagger-version: "2.0"

Original file line number Diff line number Diff line change
Expand Up @@ -2187,4 +2187,5 @@ components:
http_basic_test:
scheme: basic
type: http
x-original-swagger-version: "2.0"

1 change: 1 addition & 0 deletions samples/client/petstore/java/retrofit2/api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2187,4 +2187,5 @@ components:
http_basic_test:
scheme: basic
type: http
x-original-swagger-version: "2.0"

1 change: 1 addition & 0 deletions samples/client/petstore/java/retrofit2rx2/api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2187,4 +2187,5 @@ components:
http_basic_test:
scheme: basic
type: http
x-original-swagger-version: "2.0"

1 change: 1 addition & 0 deletions samples/client/petstore/java/retrofit2rx3/api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2187,4 +2187,5 @@ components:
http_basic_test:
scheme: basic
type: http
x-original-swagger-version: "2.0"

Original file line number Diff line number Diff line change
Expand Up @@ -2187,4 +2187,5 @@ components:
http_basic_test:
scheme: basic
type: http
x-original-swagger-version: "2.0"

1 change: 1 addition & 0 deletions samples/client/petstore/java/vertx/api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2187,4 +2187,5 @@ components:
http_basic_test:
scheme: basic
type: http
x-original-swagger-version: "2.0"

1 change: 1 addition & 0 deletions samples/client/petstore/java/webclient/api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2187,4 +2187,5 @@ components:
http_basic_test:
scheme: basic
type: http
x-original-swagger-version: "2.0"

Original file line number Diff line number Diff line change
Expand Up @@ -1037,5 +1037,6 @@
"type" : "apiKey"
}
}
}
},
"x-original-swagger-version" : "2.0"
}
Original file line number Diff line number Diff line change
Expand Up @@ -1037,5 +1037,6 @@
"type" : "apiKey"
}
}
}
},
"x-original-swagger-version" : "2.0"
}
Original file line number Diff line number Diff line change
Expand Up @@ -1037,5 +1037,6 @@
"type" : "apiKey"
}
}
}
},
"x-original-swagger-version" : "2.0"
}
Original file line number Diff line number Diff line change
Expand Up @@ -2880,5 +2880,6 @@
"type" : "http"
}
}
}
},
"x-original-swagger-version" : "2.0"
}
Original file line number Diff line number Diff line change
Expand Up @@ -1037,5 +1037,6 @@
"type" : "apiKey"
}
}
}
},
"x-original-swagger-version" : "2.0"
}
Original file line number Diff line number Diff line change
Expand Up @@ -1037,5 +1037,6 @@
"type" : "apiKey"
}
}
}
},
"x-original-swagger-version" : "2.0"
}
Original file line number Diff line number Diff line change
Expand Up @@ -1037,5 +1037,6 @@
"type" : "apiKey"
}
}
}
},
"x-original-swagger-version" : "2.0"
}
Original file line number Diff line number Diff line change
Expand Up @@ -1037,5 +1037,6 @@
"type" : "apiKey"
}
}
}
},
"x-original-swagger-version" : "2.0"
}
Original file line number Diff line number Diff line change
Expand Up @@ -1037,5 +1037,6 @@
"type" : "apiKey"
}
}
}
},
"x-original-swagger-version" : "2.0"
}
Original file line number Diff line number Diff line change
Expand Up @@ -1037,5 +1037,6 @@
"type" : "apiKey"
}
}
}
},
"x-original-swagger-version" : "2.0"
}
Original file line number Diff line number Diff line change
Expand Up @@ -2261,3 +2261,4 @@ components:
http_basic_test:
scheme: basic
type: http
x-original-swagger-version: "2.0"
Original file line number Diff line number Diff line change
Expand Up @@ -2261,3 +2261,4 @@ components:
http_basic_test:
scheme: basic
type: http
x-original-swagger-version: "2.0"
Original file line number Diff line number Diff line change
Expand Up @@ -794,3 +794,4 @@ components:
name: api_key
type: apiKey
x-apikeyInfoFunc: openapi_server.controllers.security_controller_.info_from_api_key
x-original-swagger-version: "2.0"
Original file line number Diff line number Diff line change
Expand Up @@ -794,3 +794,4 @@ components:
name: api_key
type: apiKey
x-apikeyInfoFunc: openapi_server.controllers.security_controller_.info_from_api_key
x-original-swagger-version: "2.0"
Original file line number Diff line number Diff line change
Expand Up @@ -783,3 +783,4 @@ components:
name: api_key
type: apiKey
x-apikeyInfoFunc: openapi_server.controllers.security_controller_.info_from_api_key
x-original-swagger-version: "2.0"
Original file line number Diff line number Diff line change
Expand Up @@ -1591,4 +1591,5 @@ components:
http_basic_test:
scheme: basic
type: http
x-original-swagger-version: "2.0"

Original file line number Diff line number Diff line change
Expand Up @@ -212,4 +212,5 @@ components:
required:
- required_thing
type: object
x-original-swagger-version: "2.0"

Original file line number Diff line number Diff line change
Expand Up @@ -2261,3 +2261,4 @@ components:
http_basic_test:
scheme: basic
type: http
x-original-swagger-version: "2.0"

0 comments on commit f9d6c6f

Please sign in to comment.