openapi-generator icon indicating copy to clipboard operation
openapi-generator copied to clipboard

PR for openapi-generator-maven-plugin inputSpec -- Allow jar: URLs

Open parenko opened this issue 1 year ago • 3 comments

This is a PR in response to #10016. It changes <inputSpec/> processing to:

  1. Search a classpath of Maven compilation dependencies for resources.
  2. Allow URLs of the form jar:jar-file-specific-url!/spec.yaml

In the case that a compilation classpath resource is specified, the resource URL is passed to the swagger-parser OpenAPIV3Parser instead of the <inputSpec/> string since the OpenAPIV3Parser does not have access to the Maven compilation classpath. This requires https://github.com/swagger-api/swagger-parser/issues/1592 and https://github.com/swagger-api/swagger-parser/pull/1593.

modules/openapi-generator-maven-plugin/src/test/java/org/openapitools/codegen/plugin/CodeGenMojoTest.java has been expanded to include tests for resource and URL input specs.

(This is a copy of PR #10037. I've rebased original branch on master, fixed merge conflicts and removed swagger-parser 2.0.28-SNAPSHOT since 2.1.19 is used now)

CC @wing328, @jimschubert

parenko avatar May 06 '24 05:05 parenko

can you please also add a test or 2 in https://github.com/OpenAPITools/openapi-generator/blob/master/.github/workflows/maven-plugin-tests.yaml#L44 ?

wing328 avatar May 08 '24 03:05 wing328

can you please also add a test or 2 in https://github.com/OpenAPITools/openapi-generator/blob/master/.github/workflows/maven-plugin-tests.yaml#L44 ?

Will do so. I have to fix other tests, also. I have so issues to run the build locally.

parenko avatar May 08 '24 08:05 parenko

@wing328 instead of adding another pom to https://github.com/OpenAPITools/openapi-generator/blob/master/.github/workflows/maven-plugin-tests.yaml#L44 , I've extended https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator-maven-plugin/examples/java-client.xml with another execution, pointing to a jar as inputSpec.

There are also tests in CodeGenMojoTest.java. For inputSpec as classpath, url or file there are other examples and tests, thus I did not additional examples.

parenko avatar May 19 '24 22:05 parenko

@parenko thanks for the PR, which has been merged into the master.

wing328 avatar May 21 '24 05:05 wing328