swagger-api / swagger-api/swagger-codegen
[RUBY] Json object defined with `additionalProperties` in swagger.yml gets validated against `array` datatype instead of `hash`
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
I have a JSON input object with one of its keys as another object but variable key-value pairs:
parentObject:
type: object
properties:
key1:
type: object
additionalProperties:
description: Name of custom property
type: string
example: 'Ellie'
In generated ruby wrapper, this key1 object is getting validated against array datatype instead of hash which is causing the request failure.
For example, following piece of code is not working:
input_params = MyApi::ObjectCreationApi.new({'key1'=> {'name'=>'abc', 'place'=>'bcd'}})
MyApi::ObjectsApi.new.create_object(input_params)
Swagger-codegen version
2.2.3
Suggest a fix/enhancement
Type of key1 should be matched against hash not array.
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 Ruby client generated from the swagger.yml schema, focusing on validation for an object using additionalProperties. Reproduce the shown create_object call and trace why key1 is treated as an array; done when the generated wrapper accepts its hash value and the request succeeds.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100