Skip to content
This repository was archived by the owner on Dec 25, 2024. It is now read-only.
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 @@ -2759,14 +2759,14 @@ public String defaultTemplatingEngine() {
public void preprocessOpenAPI(OpenAPI openAPI) {
String originalSpecVersion;
String xOriginalSwaggerVersion = "x-original-swagger-version";
if (openAPI.getExtensions() != null && !openAPI.getExtensions().isEmpty() && openAPI.getExtensions().containsValue(xOriginalSwaggerVersion)) {
if (openAPI.getExtensions() != null && !openAPI.getExtensions().isEmpty() && openAPI.getExtensions().containsKey(xOriginalSwaggerVersion)) {
originalSpecVersion = (String) openAPI.getExtensions().get(xOriginalSwaggerVersion);
} else {
originalSpecVersion = openAPI.getOpenapi();
}
Integer specMajorVersion = Integer.parseInt(originalSpecVersion.substring(0, 1));
if (specMajorVersion < 3) {
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");
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");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ public void testRecursiveExampleValueWithCycle() throws Exception {
Assert.assertEquals(exampleValue.trim(), expectedValue.trim());
}

@Test
public void testSpecWithTooLowVersionThrowsException() throws RuntimeException {
@Test(expectedExceptions = RuntimeException.class)
public void testSpecWithTooLowVersionThrowsException() {
final OpenAPI openAPI = TestUtils.parseSpec("src/test/resources/2_0/petstore.yaml");
final PythonClientCodegen codegen = new PythonClientCodegen();
codegen.preprocessOpenAPI(openAPI);
Expand Down