OpenAPITools / OpenAPITools/openapi-generator
[BUG][Ruby] NameError when using OneOf in json schema
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Hi,
I used the openapi-generator to build ruby code from a json schema, which is using oneOf relations for some of their attributes in the response data model.
"UserDto": {
"type": "object",
"additionalProperties": false,
"properties": {
"id": {
"type": "string",
"description": "The id of the user."
},
"fullName": {
"type": "string",
"description": "The full name of the user."
},
"settings": {
"description": "Notification settings per channel.",
"oneOf": [
{
"$ref": "#/components/schemas/NotificationSettingsDto"
}
]
}
}
},
"NotificationSettingsDto": {
"type": "object",
"additionalProperties": {
"$ref": "#/components/schemas/NotificationSettingDto"
}
},
"NotificationSettingDto": {
"type": "object",
"additionalProperties": false,
"properties": {
"send": {
"type": "boolean",
"description": "True or false to send the notification for the channel.",
"nullable": true
},
"delayInSeconds": {
"type": "integer",
"description": "The delay in seconds.",
"format": "int32",
"nullable": true
}
}
}
Building and integration into my app is working, but when calling the endpoint I get following error for the response model:
#<NameError: uninitialized constant APP::OneOfmap>
The generated code for the user_dto contains the method:
def self.openapi_types
{
:'id' => :'String',
:'full_name' => :'String',
:'settings' => :'OneOfmap''
}
end
Is this correct? I can't find any information about "OneOfmap", neither any example.
Any help is appreciated
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
No repository file or test is named in the report. Start by reproducing the schema with the Ruby generator and trace oneOf plus additionalProperties handling into the generated user_dto openapi_types method; done when the generated response model no longer references the unresolved OneOfmap constant and the endpoint response works.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100