Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CHORE[DEPENDENCIES]: bump swagger-parser => 2.0.22 #7597

Merged
merged 1 commit into from
Dec 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -1510,7 +1510,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"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sebastien-rosset I see you added this to swagger-parser, but it doesn't seem to be consumed anywhere.

Do you need to create a follow up to consume this as mentioned in #6290?

Limitation: due to issue swagger-parser #1369, achieving OAS compliance is not possible when the input document uses the OAS 2.0 schema. For OAS 2.0 documents, the legacy behavior should be used by setting the disallowAdditionalPropertiesIfNotPresent CLI option to true.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, there needs to be a follow up. Actually even better would be to ensure the 2.0 parser is converting additionalProperties properly.
With x-original-swagger-version, at least we know the source is 2.0, but if the converter is not converting properly to 3.0 (and retaining the semantics), it's still going to be a problem.

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"