Skip to content

Commit

Permalink
add serialization option to action - fix comments
Browse files Browse the repository at this point in the history
  • Loading branch information
gracekarina committed Sep 25, 2022
1 parent 263ab9b commit 9cb5477
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
19 changes: 11 additions & 8 deletions .github/actions/action.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
name: 'Swagger Parser CLI'
description: 'Uses swagger parser CLI to allow validation of a definition'
name: 'Swagger Parser'
description: 'Parses, validates, dereferences an OpenAPI definition'
inputs:
inputSpec:
description: 'file of the openapi definition'
description: 'path to OpenAPI definition file'
required: true
options:
description: 'parser options'
required: false
serializationType:
description: 'result file serialization type'
required: false
logsPath:
description: 'file of the logs messages or errors'
required: true
description: 'path to validation result file'
required: false
parserSpecPath:
description: 'path where a file can be found with parsed definition'
description: 'output path of the serialized parsed definition'
required: false
runs:
using: "composite"
Expand All @@ -26,9 +29,9 @@ runs:
distribution: 'zulu'
java-version: '11'
- name: Download JAR
run: curl -L "https://repository.sonatype.org/service/local/artifact/maven/content?r=central-proxy&g=io.swagger.parser.v3&a=swagger-parser-cli&e=jar&v=LATEST" -o swagger-parser-cli.jar
run: curl -L "https://oss.sonatype.org/service/local/repositories/snapshots/content/io/swagger/parser/v3/swagger-parser-cli/2.1.3-SNAPSHOT/swagger-parser-cli-2.1.3-20220917.171959-2.jar" -o swagger-parser-cli.jar
shell: bash
- id: execute
name: Execute Jar
run: java -jar swagger-parser-cli.jar -i ${{ inputs.inputSpec }} ${{ inputs.options }} -o ${{ inputs.parserSpecPath }} -l ${{ inputs.logsPath }}
run: java -jar swagger-parser-cli.jar ${{ inputs.inputSpec }} ${{ inputs.options }} ${{ inputs.serializationType }} -o ${{ inputs.parserSpecPath }} -l ${{ inputs.logsPath }}
shell: bash
5 changes: 4 additions & 1 deletion .github/workflows/validate-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,11 @@ jobs:
with:
inputSpec: '/home/runner/work/swagger-parser/swagger-parser/modules/swagger-parser-cli/src/test/resources/fileWithNoErrorMessages.yaml'
options: '-resolve -resolveFully'
serializationType: '-json'
logsPath: '/home/runner/work/swagger-parser/swagger-parser/modules/swagger-parser-cli/target/test-classes/parserLogs.yaml'
parserSpecPath: '/home/runner/work/swagger-parser/swagger-parser/modules/swagger-parser-cli/target/test-classes/specParsed.yaml'
parserSpecPath: '/home/runner/work/swagger-parser/swagger-parser/modules/swagger-parser-cli/target/test-classes/specParsed.json'
- run: cat /home/runner/work/swagger-parser/swagger-parser/modules/swagger-parser-cli/target/test-classes/specParsed.json
shell: bash



Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ public static List<String> readFromLocation(Namespace args) {
if(args.getString("o") != null) {
if (result.getOpenAPI() != null){
String output;
Yaml.prettyPrint(result.getOpenAPI());
if(args.getString("json") != null){
output = Json.pretty(result.getOpenAPI());
}else if(args.getString("yaml") != null){
Expand Down

0 comments on commit 9cb5477

Please sign in to comment.