swagger-api / swagger-api/swagger-codegen
[swift5] Entire path and HTTP method in operation signature
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
We've been using swagger-codegen 2 and now we're moving over to swagger-codegen 3 as we're preparing to use OpenAPI 3. When trying it out it seems that the entire path of each endpoint is added as a prefix to each operation along with the HTTP method as a suffix.
Before:
open class func copy(fileId: String) -> Observable<CopyFileCommandResponse>
After:
open class func apiV1FileFileIdCopyPost(fileId: String) -> Observable<CopyFileCommandResponse>
I've tried to find the reason for this by reading the documentation and the source code as I'm not sure how to use it. But it is hard to find any documentation describing this feature and that is why I've created this issue.
- Does this make it possible to generate two versions of the specification at the same time? Shipping a generated SDK to clients with both
func apiV1FileFileIdCopyPostandfunc apiV2FileFileIdCopyPost. - If so will the components or definitions also be versioned?
apiV1CopyFileCommandResponseandapiV2CopyFileCommandResponse. - If the API version is in the operation signature, doesn't that mean I always break the API of the generated SDK when updating to a new version of the specification, even though the same operation is used in both V1 and V2?
Swagger-codegen version
2.4.15 (99ed191d0a71daf8613d15371e381c649e325479)
3.0.22-SNAPSHOT (ad1b8bb54ce5eb1677426b5a49e80102590badc1)
Swagger declaration file content or url
2.0: https://gist.github.com/hlineholm-flir/a36f61d1d84a143d461b4cbb3772c181
3.0.1: https://gist.github.com/hlineholm-flir/bb390db34cd07742ca1d739481f2656b
Command line used for generation
swagger-codegen-cli.jar generate -l swift5 -I ./swagger.json -o ./generated-api
Suggest a fix/enhancement
- Add info about this feature in the documentation. Currently it is hard to understand what the intention is and how this is supposed to be used.
- Make it configurable. Currently I cannot configure if I want the entire path and the HTTP method in the operation signature.
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 the swagger-codegen-cli.jar generate -l swift5 -I ./swagger.json -o ./generated-api command and compare the Swagger 2.0 and OpenAPI 3.0.1 declarations in the two linked gists. Trace how the Swift 5 generator forms operation names, then document the behavior and determine the configuration and compatibility expectations described in the issue.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- openapi, swift
- Domain
- api, tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100