Description
By generating a ruby client, the models order defined in openapi_client.rb is incorrect in case where there is some inheritance.
openapi-generator version
$ openapi-generator version
4.2.2
OpenAPI declaration file content or url
petstore.yaml
openapi: 3.0.0info:
version: 1.0.0-SNAPSHOTtitle: petstoredescription: | This is the specification of Petstore with the following resources: - Petlicense:
name: MITservers:
- url: http://petstore.swagger.io/v1paths:
/pets:
get:
tags:
- petsresponses:
"200":
description: A paged array of petscontent:
application/json:
schema:
type: objectdescription: 1.0.0required:
- pet_typeproperties:
pet_type:
type: stringdiscriminator:
propertyName: pet_typemapping:
dog: "#/components/schemas/Dog"cat: "#/components/schemas/Cat"lizard: "#/components/schemas/Lizard"components:
schemas:
Pet:
type: objectrequired:
- pet_typeproperties:
pet_type:
type: stringstartDate:
type: stringexample: "2019-11-08"num:
type: integerexample: 1discriminator:
propertyName: pet_typemapping:
dog: "#/components/schemas/Dog"cat: "#/components/schemas/Cat"lizard: "#/components/schemas/Lizard"Dog:
allOf:
- $ref: "#/components/schemas/Pet"
- type: objectproperties:
bark:
type: stringCat:
allOf:
- $ref: "#/components/schemas/Pet"
- type: objectproperties:
name:
type: stringLizard:
allOf:
- $ref: "#/components/schemas/Pet"
- type: objectproperties:
lovesRocks:
type: boolean
Command line used for generation
openapi-generator generate --generator-name ruby -i petstore.yaml
Steps to reproduce
- After generating, build gem
gem build openapi_client.gemspec - Install it
gem install openapi_client-1.0.0.gem - Use it in your ruby code in
test.py file for example: `require 'openapi_client' - Execute it
ruby test.py
The following error has occured: uninitialized constant OpenapiClient::Pet (NameError)
The problem is due to openapi_client.rb file where Cat, Dogs and Lizard modules are loaded before Pet.
Suggest a fix
Rather to generate the model list from alphabetic order, generate it in the same order of OpenAPI specs file.
Description
By generating a ruby client, the models order defined in
openapi_client.rbis incorrect in case where there is some inheritance.openapi-generator version
OpenAPI declaration file content or url
petstore.yaml
Command line used for generation
Steps to reproduce
gem build openapi_client.gemspecgem install openapi_client-1.0.0.gemtest.pyfile for example: `require 'openapi_client'ruby test.pyThe following error has occured:
uninitialized constant OpenapiClient::Pet (NameError)The problem is due to
openapi_client.rbfile whereCat,DogsandLizardmodules are loaded beforePet.Suggest a fix
Rather to generate the model list from alphabetic order, generate it in the same order of OpenAPI specs file.