OpenAPITools / OpenAPITools/openapi-generator
[BUG][Swift5] Recursion error in generated code for OpenAPI spec from Bokun API docs
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)?
- Have you tested with the latest master to confirm the issue still exists?
- Have you searched for related issues/PRs?
- What's the actual output vs expected output?
- [Optional] Sponsorship to speed up the bug fix or feature request (example)
It contains syntax that cannot be expressed in Swift.
public struct A: Codable {
public var a: A // Value type 'A' cannot have a stored property that recursively contains it
public init(a: A) {
self.a = a
}
}
Description
When generating Swift5 code using the openapi-generator-cli-6.5.0.jar with the OpenAPI spec from this URL https://raw.githubusercontent.com/Bokun/api-docs/gh-pages/bokun.yaml, the following error occurred:
Value type 'RouteBookingDto' cannot have a stored property that recursively contains it.
openapi-generator version
openapi-generator-cli-6.5.0
OpenAPI declaration file content or url
https://raw.githubusercontent.com/Bokun/api-docs/gh-pages/bokun.yaml
Generation Details
java -jar ./openapi-generator-cli-6.5.0.jar generate \
-i https://raw.githubusercontent.com/Bokun/api-docs/gh-pages/bokun.yaml \
-g swift5 \
-o ./OpenAPI
Steps to reproduce
- Install openapi-generator-cli-6.5.0.
- Run the following command:
java -jar ./openapi-generator-cli-6.5.0.jar generate \
-i https://raw.githubusercontent.com/Bokun/api-docs/gh-pages/bokun.yaml \
-g swift5 \
-o ./OpenAPI
Related issues/PRs
Suggest a fix
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
Run the reported java -jar generation command against bokun.yaml with the swift5 generator and inspect the generated RouteBookingDto and example.swift output. Confirm the recursive value-type error, then define a generator-level change that produces Swift-compilable output and verify generation no longer creates the failing recursive declaration.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, openapi, swift
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100