OpenAPITools / OpenAPITools/openapi-generator
[BUG][OBJC] Boolean header not being recognised as boolean type
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)?
- What's the version of OpenAPI Generator used?
- Have you search for related issues/PRs?
- What's the actual output vs expected output?
- [Optional] Bounty to sponsor the fix (example)
Description
In my Petstore I've added in an input header of type boolean. When I generate the Objc code, the header hasn't been recognised as a boolean, so the relevant template snippet hasn't generated the correct code.
The consequence is that when when the code is run, and the OAIApiClient goes to set the header in the request, the app crashes with the error Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFBoolean length]: unrecognized selector sent to instance. This is of course because the type of the value being set is of NSCFBoolean and not a NSString because the snippet wasn't generated to convert the boolean to a string representation for the HTTP request header.
openapi-generator version
4.3.1
OpenAPI declaration file content or url
https://github.com/kierans/openapi-generator-objc-sample
Command line used for generation
$ ./gradlew generateObjc
Steps to reproduce
- Add an input header of type boolean
- Generate objc code.
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
Start with modules/openapi-generator/src/main/resources/objc/api-body.mustache, especially the header-generation snippet linked in the report, and compare it with the generated code in the objc sample. Run ./gradlew generateObjc using the Petstore specification, then verify that a boolean header is converted correctly for OAIApiClient rather than causing the reported crash.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- objective-c, openapi
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 38/100