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

this fixes a bug where the parser would return
null when missing parameters rather than reporting
some useful error.

Fixes N/A
This commit is contained in:
Cody Mikol 2020-12-08 02:18:07 -05:00 committed by GitHub
parent 9e0badb3d7
commit f9d6c6fb21
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
44 changed files with 64 additions and 14 deletions

View File

@ -472,14 +472,22 @@ public class InlineModelResolver {
* @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

View File

@ -28,6 +28,7 @@ import io.swagger.v3.oas.models.responses.ApiResponse;
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;
@ -927,7 +928,7 @@ public class InlineModelResolverTest {
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

View File

@ -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>

View File

@ -2126,3 +2126,4 @@ components:
http_basic_test:
scheme: basic
type: http
x-original-swagger-version: "2.0"

View File

@ -2126,3 +2126,4 @@ components:
http_basic_test:
scheme: basic
type: http
x-original-swagger-version: "2.0"

View File

@ -2187,4 +2187,5 @@ components:
http_basic_test:
scheme: basic
type: http
x-original-swagger-version: "2.0"

View File

@ -2187,4 +2187,5 @@ components:
http_basic_test:
scheme: basic
type: http
x-original-swagger-version: "2.0"

View File

@ -2187,4 +2187,5 @@ components:
http_basic_test:
scheme: basic
type: http
x-original-swagger-version: "2.0"

View File

@ -2187,4 +2187,5 @@ components:
http_basic_test:
scheme: basic
type: http
x-original-swagger-version: "2.0"

View File

@ -2187,4 +2187,5 @@ components:
http_basic_test:
scheme: basic
type: http
x-original-swagger-version: "2.0"

View File

@ -2187,4 +2187,5 @@ components:
http_basic_test:
scheme: basic
type: http
x-original-swagger-version: "2.0"

View File

@ -2187,4 +2187,5 @@ components:
http_basic_test:
scheme: basic
type: http
x-original-swagger-version: "2.0"

View File

@ -2187,4 +2187,5 @@ components:
http_basic_test:
scheme: basic
type: http
x-original-swagger-version: "2.0"

View File

@ -2187,4 +2187,5 @@ components:
http_basic_test:
scheme: basic
type: http
x-original-swagger-version: "2.0"

View File

@ -2187,4 +2187,5 @@ components:
http_basic_test:
scheme: basic
type: http
x-original-swagger-version: "2.0"

View File

@ -2187,4 +2187,5 @@ components:
http_basic_test:
scheme: basic
type: http
x-original-swagger-version: "2.0"

View File

@ -2187,4 +2187,5 @@ components:
http_basic_test:
scheme: basic
type: http
x-original-swagger-version: "2.0"

View File

@ -2187,4 +2187,5 @@ components:
http_basic_test:
scheme: basic
type: http
x-original-swagger-version: "2.0"

View File

@ -2187,4 +2187,5 @@ components:
http_basic_test:
scheme: basic
type: http
x-original-swagger-version: "2.0"

View File

@ -2187,4 +2187,5 @@ components:
http_basic_test:
scheme: basic
type: http
x-original-swagger-version: "2.0"

View File

@ -2187,4 +2187,5 @@ components:
http_basic_test:
scheme: basic
type: http
x-original-swagger-version: "2.0"

View File

@ -2187,4 +2187,5 @@ components:
http_basic_test:
scheme: basic
type: http
x-original-swagger-version: "2.0"

View File

@ -2187,4 +2187,5 @@ components:
http_basic_test:
scheme: basic
type: http
x-original-swagger-version: "2.0"

View File

@ -2187,4 +2187,5 @@ components:
http_basic_test:
scheme: basic
type: http
x-original-swagger-version: "2.0"

View File

@ -2187,4 +2187,5 @@ components:
http_basic_test:
scheme: basic
type: http
x-original-swagger-version: "2.0"

View File

@ -2187,4 +2187,5 @@ components:
http_basic_test:
scheme: basic
type: http
x-original-swagger-version: "2.0"

View File

@ -1037,5 +1037,6 @@
"type" : "apiKey"
}
}
}
},
"x-original-swagger-version" : "2.0"
}

View File

@ -1037,5 +1037,6 @@
"type" : "apiKey"
}
}
}
},
"x-original-swagger-version" : "2.0"
}

View File

@ -1037,5 +1037,6 @@
"type" : "apiKey"
}
}
}
},
"x-original-swagger-version" : "2.0"
}

View File

@ -2880,5 +2880,6 @@
"type" : "http"
}
}
}
},
"x-original-swagger-version" : "2.0"
}

View File

@ -1037,5 +1037,6 @@
"type" : "apiKey"
}
}
}
},
"x-original-swagger-version" : "2.0"
}

View File

@ -1037,5 +1037,6 @@
"type" : "apiKey"
}
}
}
},
"x-original-swagger-version" : "2.0"
}

View File

@ -1037,5 +1037,6 @@
"type" : "apiKey"
}
}
}
},
"x-original-swagger-version" : "2.0"
}

View File

@ -1037,5 +1037,6 @@
"type" : "apiKey"
}
}
}
},
"x-original-swagger-version" : "2.0"
}

View File

@ -1037,5 +1037,6 @@
"type" : "apiKey"
}
}
}
},
"x-original-swagger-version" : "2.0"
}

View File

@ -1037,5 +1037,6 @@
"type" : "apiKey"
}
}
}
},
"x-original-swagger-version" : "2.0"
}

View File

@ -2261,3 +2261,4 @@ components:
http_basic_test:
scheme: basic
type: http
x-original-swagger-version: "2.0"

View File

@ -2261,3 +2261,4 @@ components:
http_basic_test:
scheme: basic
type: http
x-original-swagger-version: "2.0"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -1591,4 +1591,5 @@ components:
http_basic_test:
scheme: basic
type: http
x-original-swagger-version: "2.0"

View File

@ -212,4 +212,5 @@ components:
required:
- required_thing
type: object
x-original-swagger-version: "2.0"

View File

@ -2261,3 +2261,4 @@ components:
http_basic_test:
scheme: basic
type: http
x-original-swagger-version: "2.0"