Skip to content
This repository was archived by the owner on Dec 25, 2024. It is now read-only.

Commit d6a611b

Browse files
authored
Fixes low spec version bug (#74)
1 parent 5fc90e2 commit d6a611b

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

modules/openapi-json-schema-generator/src/main/java/org/openapitools/codegen/languages/PythonClientCodegen.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2759,14 +2759,14 @@ public String defaultTemplatingEngine() {
27592759
public void preprocessOpenAPI(OpenAPI openAPI) {
27602760
String originalSpecVersion;
27612761
String xOriginalSwaggerVersion = "x-original-swagger-version";
2762-
if (openAPI.getExtensions() != null && !openAPI.getExtensions().isEmpty() && openAPI.getExtensions().containsValue(xOriginalSwaggerVersion)) {
2762+
if (openAPI.getExtensions() != null && !openAPI.getExtensions().isEmpty() && openAPI.getExtensions().containsKey(xOriginalSwaggerVersion)) {
27632763
originalSpecVersion = (String) openAPI.getExtensions().get(xOriginalSwaggerVersion);
27642764
} else {
27652765
originalSpecVersion = openAPI.getOpenapi();
27662766
}
27672767
Integer specMajorVersion = Integer.parseInt(originalSpecVersion.substring(0, 1));
27682768
if (specMajorVersion < 3) {
2769-
throw new RuntimeException("Your spec version of "+originalSpecVersion+" is too low. python-experimental only works with specs with version >= 3.X.X. Please use a tool like Swagger Editor or Swagger Converter to convert your spec to v3");
2769+
throw new RuntimeException("Your spec version of "+originalSpecVersion+" is too low. " + getName() + " only works with specs with version >= 3.X.X. Please use a tool like Swagger Editor or Swagger Converter to convert your spec to v3");
27702770
}
27712771
}
27722772

modules/openapi-json-schema-generator/src/test/java/org/openapitools/codegen/python/PythonClientTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ public void testRecursiveExampleValueWithCycle() throws Exception {
5959
Assert.assertEquals(exampleValue.trim(), expectedValue.trim());
6060
}
6161

62-
@Test
63-
public void testSpecWithTooLowVersionThrowsException() throws RuntimeException {
62+
@Test(expectedExceptions = RuntimeException.class)
63+
public void testSpecWithTooLowVersionThrowsException() {
6464
final OpenAPI openAPI = TestUtils.parseSpec("src/test/resources/2_0/petstore.yaml");
6565
final PythonClientCodegen codegen = new PythonClientCodegen();
6666
codegen.preprocessOpenAPI(openAPI);

0 commit comments

Comments
 (0)