swagger-api / swagger-api/swagger-codegen
[SWIFT] Bug Generating Code From JSON With Namespaces
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
In the swagger API documentation all the models have their namespaces prefixed (comes from C# project), for example if the model name is Model, then the full name will be something like Project.Namespace.Something.Model
When generating using swagger-codegen, to Swift or Kotlin (haven't tried anything else), the class names and their file name get generated as ProjectNamespaceSomethingModel instead of just Model
We tried to fix this behavior by replacing the dots in the names with forward slashes, so the full names become Project/Namespace/Something/Model in the JSON, but it only solved the issue when generating Kotlin (the file/class names are ok, everything is generated into their respective folders), but Swift generation still shows the same behaviour (all the models residing in the same folder SwaggerClient/Classes/Swaggers/Models/)
Is this intended behavior or indeed a bug?
Swagger-codegen version
swagger-codegen: stable 2.3.1
Swagger declaration file content or url
Gist: https://gist.github.com/VBasinovas/4bcfe613ab97aca11bfb0a5c023c8fe1
Command line used for generation
swagger-codegen generate -i documentation.json -l swift -o ./api-code/swift
swagger-codegen generate -i documentation.json -l kotlin -o ./api-code/kotlin
Steps to reproduce
Just generating the code from provided json with provided command line produces the issue described
Related issues/PRs
Suggest a fix/enhancement
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 provided documentation.json or gist and run the Swift and Kotlin generation commands from the issue. Compare the generated model names, class names, and directories, then trace the relevant language-generator behavior. Done means Swift handles namespaced models consistently with the expected Model names and appropriate output layout.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- kotlin, openapi, swift
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100