Skip to content

OpenAPI 3.1.x support #546

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

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
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 @@ -27,8 +27,8 @@ public enum APISpecType {
SWAGGER_API_1X_YAML("Swagger 1.x (YAML)", YAML),
SWAGGER_API_20("Swagger 2.0", JSON),
SWAGGER_API_20_YAML("Swagger 2.0 (YAML)", YAML),
OPEN_API_30("Open API 3.0", JSON),
OPEN_API_30_YAML("Open API 3.0 (YAML)", YAML),
OPEN_API_30("Open API 3.x", JSON),
OPEN_API_30_YAML("Open API 3.x (YAML)", YAML),
WSDL_API("WSDL", ".xml"),
WADL_API("Web Application Description Language (WADL)", ".wadl"),
ODATA_V2("OData V2 (converted to OpenAPI 3.0.1)", METADATA, "Given OData specification is converted into an OpenAPI 3 specification.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,10 @@ public boolean parse(byte[] apiSpecificationContent) {
if (this.mapper == null) return false;
openApiNode = this.mapper.readTree(apiSpecificationContent);
LOG.debug("openapi tag value : {}", openApiNode.get(OPENAPI));
return openApiNode.has(OPENAPI) && openApiNode.get(OPENAPI).asText().startsWith("3.0.");
return openApiNode.has(OPENAPI) && openApiNode.get(OPENAPI).asText().startsWith("3.");
} catch (Exception e) {
if (LOG.isDebugEnabled()) {
LOG.error("No OpenAPI 3.0 specification.", e);
LOG.error("No OpenAPI 3.x specification.", e);
}
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.axway.apim.lib.CoreParameters;
import com.axway.apim.lib.error.AppException;
import com.axway.apim.lib.utils.Utils;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.commons.io.IOUtils;
import org.apache.http.util.Asserts;
Expand Down Expand Up @@ -43,6 +44,23 @@ public void getAPISpecificationOpenApi() throws AppException {
Assert.assertNotNull(apiSpecification.getApiSpecificationContent());
}

@Test
public void getAPISpecificationOpenApi31() throws AppException {
String specDirPath = classLoader.getResource("com/axway/apim/adapter/spec").getFile();
APISpecification apiSpecification = APISpecificationFactory.getAPISpecification("openapi31.json", specDirPath, "petstore");
Assert.assertEquals(APISpecification.APISpecType.valueOf("OPEN_API_30"), apiSpecification.getAPIDefinitionType());
Assert.assertNotNull(apiSpecification.getDescription());
Assert.assertNotNull(apiSpecification.getApiSpecificationContent());
// openapi 3.1 specific attribute
ObjectMapper mapper = apiSpecification.getMapper();
try {
JsonNode node = mapper.readTree(apiSpecification.getApiSpecificationContent());
Assert.assertNotNull(node.get("info").get("summary").asText());
} catch (IOException e) {
throw new RuntimeException(e);
}
}

@Test
public void getAPISpecificationSwagger2() throws AppException {
String specDirPath = classLoader.getResource("com/axway/apim/adapter/spec").getFile();
Expand Down
Loading