Skip to content

Commit

Permalink
add fix for issue1780
Browse files Browse the repository at this point in the history
  • Loading branch information
gracekarina committed Aug 12, 2022
1 parent cdb4bc9 commit be358d5
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 5 deletions.
5 changes: 1 addition & 4 deletions .github/actions/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@ runs:
distribution: 'zulu'
java-version: '11'
- name: Download JAR
run: curl 'https://oss.sonatype.org/service/local/repositories/snapshots/content/io/swagger/parser/v3/swagger-parser-cli/2.1.2-SNAPSHOT/swagger-parser-cli-2.1.2-20220719.144003-1.jar' -o swagger-parser-cli.jar
shell: bash
- name: Location
run: pwd
run: curl 'https://oss.sonatype.org/service/local/repositories/snapshots/content/io/swagger/parser/v3/swagger-parser-cli/2.1.2-SNAPSHOT/swagger-parser-cli-2.1.2-20220812.023913-3.jar' -o swagger-parser-cli.jar
shell: bash
- name: Execute Jar
run: java -jar ./swagger-parser-cli.jar ${{ inputs.inputSpec }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,11 @@ public OpenAPI parseRoot(JsonNode node, ParseResult result, String path) {
} else if (value.startsWith("3.1")) {
result.openapi31(true);
}
openAPI.setOpenapi(value);
if (!value.startsWith("3.0.") && !value.startsWith("3.1.")){
result.warning(location, "The provided definition does not specify a valid version field");
}
openAPI.setOpenapi(value);


ObjectNode obj = getObject("info", rootNode, true, location, result);
if (obj != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,28 @@ public class OpenAPIV3ParserTest {
protected int serverPort = getDynamicPort();
protected WireMockServer wireMockServer;

@Test
public void testIssue1780() {
ParseOptions options = new ParseOptions();
options.setInferSchemaType(false);
String defaultSchemaType = "---\n" +
"openapi: '3.0'\n" +
"info:\n" +
" description: This is a credit card account service tier 3 microservice\n" +
" title: SC-CCS-CCSRV_AC Credit Card Account Service\n" +
" version: 1.0.0\n" +
"tags:\n" +
"- name: creditCardAccount\n" +
" description: Credit Card Accounts\n" +
"paths: {}\n" +
"x-ibm-configuration: {}";
SwaggerParseResult result = new OpenAPIV3Parser().readContents(defaultSchemaType, null, options);
OpenAPI openAPI = result.getOpenAPI();
assertNotNull(openAPI);
assertTrue(result.getMessages().contains("The provided definition does not specify a valid version field"));

}

@Test
public void testIssue1758() throws Exception{
ParseOptions options = new ParseOptions();
Expand Down

0 comments on commit be358d5

Please sign in to comment.