[jaxrs-cfx][server] bin/jaxrs-cxf-petstore-server.sh does not generate required files
Created by: grokify
Description
When adding new tests, builds fail because new endpoints are not added to samples/server/petstore/jaxrs-cxf
This happens because many files exist and thus are not overwritten.
This is generated by bin/jaxrs-cxf-petstore-server.sh
which is run by all three of the following:
bin/jaxrs-cxf-petstore-server.sh
bin/java-jaxrs-petstore-server-all.sh
bin/utils/ensure-up-to-date
An example of this is here:
https://github.com/OpenAPITools/openapi-generator/pull/382#issuecomment-400714290
openapi-generator version
3.0.3
OpenAPI declaration file content or url
Command line used for generation
Any of the following:
$ bin/jaxrs-cxf-petstore-server.sh
$ bin/java-jaxrs-petstore-server-all.sh
$ bin/utils/ensure-up-to-date
Steps to reproduce
Generate jaxrs-cxf sample with new endpoint and commit.
Here is an example:
https://circleci.com/gh/grokify/openapi-generator/38
[ERROR] COMPILATION ERROR :
[ERROR] /home/circleci/OpenAPITools/openapi-generator/samples/server/petstore/jaxrs-cxf/src/main/java/org/openapitools/api/impl/FakeApiServiceImpl.java:[32,8] org.openapitools.api.impl.FakeApiServiceImpl is not abstract and does not override abstract method testBodyWithFileSchema(org.openapitools.model.FileSchemaTestClass) in org.openapitools.api.FakeApi
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project openapi-cxf-server: Compilation failure
[ERROR] /home/circleci/OpenAPITools/openapi-generator/samples/server/petstore/jaxrs-cxf/src/main/java/org/openapitools/api/impl/FakeApiServiceImpl.java:[32,8] org.openapitools.api.impl.FakeApiServiceImpl is not abstract and does not override abstract method testBodyWithFileSchema(org.openapitools.model.FileSchemaTestClass) in org.openapitools.api.FakeApi
[ERROR] -> [Help 1]
Related issues/PRs
This has been experienced when adding new endpoints to the Petstore spec for testing.
- https://github.com/OpenAPITools/openapi-generator/pull/382
- https://github.com/OpenAPITools/openapi-generator/pull/433
Suggest a fix/enhancement
A simple fix is to remove the output directory first as described below. This approach has worked for me twice now, however, it seems a more generic solution may be to use .openapi-generator-ignore
and replace writeOptional
. I've taken a quick look and will examine more.
- https://github.com/swagger-api/swagger-codegen/issues/3100
- https://github.com/swagger-api/swagger-codegen/issues/3991
rm -rf samples/server/petstore/jaxrs-cxf
diff --git a/bin/jaxrs-cxf-petstore-server.sh b/bin/jaxrs-cxf-petstore-server.sh
index 6846f2e..0fc6564 100755
--- a/bin/jaxrs-cxf-petstore-server.sh
+++ b/bin/jaxrs-cxf-petstore-server.sh
@@ -25,6 +25,8 @@ then
mvn -B clean package
fi
+rm -rf samples/server/petstore/jaxrs-cxf
+
# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="generate -t modules/openapi-generator/src/main/resources/JavaJaxRS/cxf -i modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -g jaxrs-cxf -o samples/server/petstore/jaxrs-cxf -DhideGenerationTimestamp=true --additional-properties serverPort=8082 $@"