Skip to content
This repository was archived by the owner on Nov 24, 2022. 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 @@ -141,7 +141,9 @@ public SwaggerParseResult convert(SwaggerDeserializationResult parse) {
openAPI.setExternalDocs(convert(swagger.getExternalDocs()));
}

openAPI.setInfo(convert(swagger.getInfo()));
if (swagger.getInfo() != null) {
openAPI.setInfo(convert(swagger.getInfo()));
}

openAPI.setServers(convert(swagger.getSchemes(), swagger.getHost(), swagger.getBasePath()));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ public class V2ConverterTest {
private static final String ISSUE_673_YAML = "issue-673.yaml";
private static final String ISSUE_676_JSON = "issue-676.json";
private static final String ISSUE_708_YAML = "issue-708.yaml";
private static final String ISSUE_755_YAML = "issue-755.yaml";

private static final String API_BATCH_PATH = "/api/batch/";
private static final String PETS_PATH = "/pets";
Expand Down Expand Up @@ -650,6 +651,12 @@ public void testSwaggerParseResultHasMessage() throws Exception {
assertNotNull(result.getMessages());
}

@Test(description = "OpenAPI v2 converter - Conversion of a spec without a info section")
public void testIssue755() throws Exception {
final OpenAPI oas = getConvertedOpenAPIFromJsonFile(ISSUE_755_YAML);
assertNotNull(oas);
}

private OpenAPI getConvertedOpenAPIFromJsonFile(String file) throws IOException, URISyntaxException {
SwaggerConverter converter = new SwaggerConverter();
String swaggerAsString = new String(Files.readAllBytes(Paths.get(getClass().getClassLoader().getResource(file).toURI())));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
swagger: '2.0'
host: petstore.swagger.io
basePath: /v2
schemes:
- http
paths:
/ping:
post:
summary: test
description: 'test it'
operationId: pingOp
responses:
'200':
description: OK