diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..52208bc --- /dev/null +++ b/.gitignore @@ -0,0 +1,73 @@ +# Created by https://www.toptal.com/developers/gitignore/api/maven,java +# Edit at https://www.toptal.com/developers/gitignore?templates=maven,java + +# Created by https://www.toptal.com/developers/gitignore/api/visualstudiocode +# Edit at https://www.toptal.com/developers/gitignore?templates=visualstudiocode + +### VisualStudioCode ### +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +!.vscode/*.code-snippets + +# Local History for Visual Studio Code +.history/ + +# Built Visual Studio Code Extensions +*.vsix + +### VisualStudioCode Patch ### +# Ignore all local history of files +.history +.ionide + +# End of https://www.toptal.com/developers/gitignore/api/visualstudiocode + +### Java ### +# Compiled class file +*.class + +# Log file +*.log + +# BlueJ files +*.ctxt + +# Mobile Tools for Java (J2ME) +.mtj.tmp/ + +# Package Files # +*.jar +*.war +*.nar +*.ear +*.zip +*.tar.gz +*.rar + +# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml +hs_err_pid* +replay_pid* + +### Maven ### +target/ +pom.xml.tag +pom.xml.releaseBackup +pom.xml.versionsBackup +pom.xml.next +release.properties +dependency-reduced-pom.xml +buildNumber.properties +.mvn/timing.properties +# https://github.com/takari/maven-wrapper#usage-without-binary-jar +.mvn/wrapper/maven-wrapper.jar + +# Eclipse m2e generated files +# Eclipse Core +.project +# JDT-specific (Eclipse Java Development Tools) +.classpath + +# End of https://www.toptal.com/developers/gitignore/api/maven,java \ No newline at end of file diff --git a/api-spec-bundler/.vscode/settings.json b/api-spec-bundler/.vscode/settings.json new file mode 100644 index 0000000..1b5ba53 --- /dev/null +++ b/api-spec-bundler/.vscode/settings.json @@ -0,0 +1,5 @@ +{ + "java.compile.nullAnalysis.mode": "automatic", + "java.configuration.updateBuildConfiguration": "interactive", + "java.debug.settings.onBuildFailureProceed": true +} \ No newline at end of file diff --git a/api-spec-bundler/project/pom.xml b/api-spec-bundler/project/pom.xml new file mode 100644 index 0000000..371c1b9 --- /dev/null +++ b/api-spec-bundler/project/pom.xml @@ -0,0 +1,80 @@ + + + + 4.0.0 + + com.example.asc_api_spec_bundler + asc_api_spec_bundler + 1.0-SNAPSHOT + + asc_api_spec_bundler + + http://www.example.com + + + UTF-8 + 1.8 + 1.8 + + + + + junit + junit + 4.11 + test + + + io.swagger.parser.v3 + swagger-parser + 2.1.15 + + + + + + + + + maven-clean-plugin + 3.1.0 + + + + maven-resources-plugin + 3.0.2 + + + maven-compiler-plugin + 3.8.0 + + + maven-surefire-plugin + 2.22.1 + + + maven-jar-plugin + 3.0.2 + + + maven-install-plugin + 2.5.2 + + + maven-deploy-plugin + 2.8.2 + + + + maven-site-plugin + 3.7.1 + + + maven-project-info-reports-plugin + 3.0.0 + + + + + diff --git a/api-spec-bundler/project/src/main/java/com/example/asc_swagger_validate/App.java b/api-spec-bundler/project/src/main/java/com/example/asc_swagger_validate/App.java new file mode 100644 index 0000000..126dafe --- /dev/null +++ b/api-spec-bundler/project/src/main/java/com/example/asc_swagger_validate/App.java @@ -0,0 +1,33 @@ +package com.example.asc_swagger_validate; + +import java.io.IOException; +import java.io.PrintWriter; + +import io.swagger.parser.OpenAPIParser; +import io.swagger.v3.core.util.Yaml; +import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.parser.core.models.ParseOptions; +import io.swagger.v3.parser.core.models.SwaggerParseResult; + +public class App { + public static void main(String[] args) { + String swaggerFilePath = "path_to_swagger.yaml"; + ParseOptions parseOptions = new ParseOptions(); + // parseOptions.setResolve(true); // implicit + parseOptions.setResolveFully(true); + parseOptions.setFlatten(true); + parseOptions.setValidateExternalRefs(true); + parseOptions.setValidateInternalRefs(true); + parseOptions.setSafelyResolveURL(true); + SwaggerParseResult result = new OpenAPIParser().readLocation(swaggerFilePath, null, parseOptions); + result.getMessages().forEach(System.out::println); + OpenAPI openAPI = result.getOpenAPI(); + try { + PrintWriter out = new PrintWriter("path_to_bundle.yaml"); + Yaml.pretty().writeValue(out, openAPI); + } catch (IOException e) { + e.printStackTrace(); + } + } + +} \ No newline at end of file diff --git a/api-spec-bundler/project/src/test/java/com/example/asc_swagger_validate/AppTest.java b/api-spec-bundler/project/src/test/java/com/example/asc_swagger_validate/AppTest.java new file mode 100644 index 0000000..7b3ea83 --- /dev/null +++ b/api-spec-bundler/project/src/test/java/com/example/asc_swagger_validate/AppTest.java @@ -0,0 +1,20 @@ +package com.example.asc_swagger_validate; + +import static org.junit.Assert.assertTrue; + +import org.junit.Test; + +/** + * Unit test for simple App. + */ +public class AppTest +{ + /** + * Rigorous Test :-) + */ + @Test + public void shouldAnswerWithTrue() + { + assertTrue( true ); + } +}