swagger-api / swagger-api/swagger-codegen
[Java] Create public variables for endpoints
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
Please create public static final variables for endpoints. For example currently we have this:
@javax.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2019-07-22T09:19:43.787+02:00[Africa/Harare]")
@Api(value = "stuff", description = "the stuff API")
public interface StuffApi {
@ApiOperation(value = "Get stuff", nickname = "getStuff", notes = "Get stuff, response = Stuff.class, tags={ })
@ApiResponses(value = {
@ApiResponse(code = 200, message = "good stuff", response = StuffList.class),
@RequestMapping(value = "/stuff" ...
This is ok, but if I write a integration test I have to do this:
stubFor(post(urlEqualTo("/stuff"))
Swagger-codegen version
3
Suggest a fix/enhancement
@javax.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2019-07-22T09:19:43.787+02:00[Africa/Harare]")
@Api(value = "stuff", description = "the stuff API")
public interface StuffApi {
public static final String STUFF = "/stuff";
@ApiOperation(value = "Get stuff", nickname = "getStuff", notes = "Get stuff, response = Stuff.class, tags={ })
@ApiResponses(value = {
@ApiResponse(code = 200, message = "good stuff", response = StuffList.class),
@RequestMapping(value =STUFF ...
}
And now my test looks like this:
stubFor(post(urlEqualTo(STUFF))..
Which means I can with an IDE easily go to the implementation (and not do a Search through entire codebase for the endpoint)
Thanks
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 by tracing the Java SpringCodegen template that emits StuffApi and its @RequestMapping value; no repository file or test is named in the issue. Verify that generated interfaces expose a public static final endpoint constant and use it in the mapping, then confirm an integration test can reference that constant.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api, tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100