OpenAPITools / OpenAPITools/openapi-generator
[BUG][jaxrs-cxf-extended][server] Certain data types not handled correctly
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Bug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
- Have you validated the input using an OpenAPI validator (example)?
- What's the version of OpenAPI Generator used?
- Have you search for related issues/PRs?
- What's the actual output vs expected output?
- [Optional] Bounty to sponsor the fix (example)
Description
The recently added jaxrs-cxf-extended generator has a corresponding samples/jaxrs-cxf-petstore-server-test-data, whose generated tests actually invoke the dummy services. Several of these tests fail on account of problems handling certain data types such as Attachment and enums. Consequently, the failing tests are now annotated with @Ignore but the problems still need to be investigated:
- org.openapitools.api.FakeApiTest
- testEndpointParametersTest()
- testEnumParametersTest()
- testJsonFormDataTest()
- org.openapitools.api.PetApiTest
- updatePetWithFormTest()
- uploadFileTest()
- uploadFileWithRequiredFileTest()
openapi-generator version
4.0.0-SNAPSHOT
OpenAPI declaration file content or url
openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml
Command line used for generation
generate --artifact-id jaxrs-cxf-petstore-server-test-data -t modules/openapi-generator/src/main/resources/JavaJaxRS/cxf-ext -i modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -g jaxrs-cxf-extended -o samples/server/petstore/jaxrs-cxf-test-data -DhideGenerationTimestamp=true -DuseAnnotatedBasePath=true --generate-alias-as-model --additional-properties java8=true,generateSpringApplication=true,generateSpringBootApplication=true,generateOperationBody=true,loadTestDataFromFile=true
Steps to reproduce
Generate using bin/jaxrs-cxf-petstore-server-test-data.sh, build the POM, then run the tests.
Related issues/PRs
See also PR#https://github.com/OpenAPITools/openapi-generator/pull/1879.
Suggest a fix
I've spent a fair amount of time debugging this without arriving at an understanding of the root cause. I don't know enough about Apache CXF internals to see what the problem is and fix it. I suspect we haven't seen similar issues with the other samples generated from petstore-with-fake-endpoints-models-for-testing.yaml simply because they don't actually start a server and invoke operations on it.
I've created this in advance of PR acceptance so that the code I'm committing can refer to this bug report as a known issue.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with bin/jaxrs-cxf-petstore-server-test-data.sh and the generated samples/server/petstore/jaxrs-cxf-test-data project, then build its POM and run the ignored tests in FakeApiTest and PetApiTest. Compare failures for endpoint parameters, enums, form data, and file uploads against openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml. Done means the affected tests can run without @Ignore and pass.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, openapi
- Domain
- api, backend, testing
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 32/100