swagger-api / swagger-api/swagger-codegen

[JaxRsCxfServer] Improvements for generated Unittests and Attachments

Open
#4,513 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Enhancement: General help wanted Server: Java
Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

Description

From #4088:

1.) currently in the tests the api invocations are commented out and thus cannot be compiled.
Wouldn't it be good to activate them and run the CI maven build with -DskipTests?

2.) Handling CXF Attachments is not totally intuitive, do you think it makes sense to add an assistance snippet here like this at api_test.mustache (for #isFile):

InputStream mybytesInput = new FileInputStream("....");
org.apache.cxf.jaxrs.ext.multipart.ContentDisposition cd = new org.apache.cxf.jaxrs.ext.multipart.ContentDisposition("attachment;filename=file.txt");
Attachment attachment = new Attachment("file", mybytesInput, cd);

or does that go too far and we should leave with the default Attachment attachment = null;?

Swagger-codegen version

2.2.2-SNAPSHOT

Related issues

#4088 Minor improvements JaxRsCXFServer

Suggest a Fix

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the api_test.mustache template and inspect the generated JaxRsCxfServer unit tests, especially the commented API invocations and the #isFile Attachment handling. Run the Maven build with -DskipTests to check compilation. Done means the requested test generation changes are agreed, compile successfully, and use a documented attachment approach.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
backend, testing
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.