You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi,
I'm not sure what i will describe is a bug; I prefer to give you some clues and have a little chat before openning a bug.
Context:
I fetch a swagger generated from one of my colleagues who is using Swashbuckle and the inheritance for the Dog schema use the following syntax:
When generate python flask server, the imports are kinda broken. docker run --rm -v "${PWD}:/local" openapitools/openapi-generator-cli:v7.6.0 generate -i /local/test.yaml -g python-flask -o /local/dist
fromdatetimeimportdate, datetime# noqa: F401fromtypingimportList, Dict# noqa: F401fromopenapi_server.models.base_modelimportModelfromopenapi_server.models.one_ofobjectimportOneOfobjectfromopenapi_serverimportutilfromopenapi_server.models.one_ofobjectimportOneOfobject# noqa: E501classDog(Model):
"""NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). Do not edit the class manually. """def__init__(self, food_eaten=None): # noqa: E501"""Dog - a model defined in OpenAPI :param food_eaten: The food_eaten of this Dog. # noqa: E501 :type food_eaten: List[OneOfobject] """self.openapi_types= {
'food_eaten': List[OneOfobject]
}
self.attribute_map= {
'food_eaten': 'food_eaten'
}
self._food_eaten=food_eaten@classmethoddeffrom_dict(cls, dikt) ->'Dog':
"""Returns the dict as a model :param dikt: A dict. :type: dict :return: The Dog of this Dog. # noqa: E501 :rtype: Dog """returnutil.deserialize_model(dikt, cls)
@propertydeffood_eaten(self) ->List[OneOfobject]:
"""Gets the food_eaten of this Dog. :return: The food_eaten of this Dog. :rtype: List[OneOfobject] """returnself._food_eaten@food_eaten.setterdeffood_eaten(self, food_eaten: List[OneOfobject]):
"""Sets the food_eaten of this Dog. :param food_eaten: The food_eaten of this Dog. :type food_eaten: List[OneOfobject] """self._food_eaten=food_eaten
I saw on swagger.io that the syntax of allOf should be the following one:
When i'm using this one, the imports are correct (working):
fromdatetimeimportdate, datetime# noqa: F401fromtypingimportList, Dict# noqa: F401fromopenapi_server.models.base_modelimportModelfromopenapi_server.models.dog_all_of_food_eatenimportDogAllOfFoodEatenfromopenapi_serverimportutilfromopenapi_server.models.dog_all_of_food_eatenimportDogAllOfFoodEaten# noqa: E501classDog(Model):
"""NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). Do not edit the class manually. """def__init__(self, food_eaten=None): # noqa: E501"""Dog - a model defined in OpenAPI :param food_eaten: The food_eaten of this Dog. # noqa: E501 :type food_eaten: List[DogAllOfFoodEaten] """self.openapi_types= {
'food_eaten': List[DogAllOfFoodEaten]
}
self.attribute_map= {
'food_eaten': 'food_eaten'
}
self._food_eaten=food_eaten@classmethoddeffrom_dict(cls, dikt) ->'Dog':
"""Returns the dict as a model :param dikt: A dict. :type: dict :return: The Dog of this Dog. # noqa: E501 :rtype: Dog """returnutil.deserialize_model(dikt, cls)
@propertydeffood_eaten(self) ->List[DogAllOfFoodEaten]:
"""Gets the food_eaten of this Dog. :return: The food_eaten of this Dog. :rtype: List[DogAllOfFoodEaten] """returnself._food_eaten@food_eaten.setterdeffood_eaten(self, food_eaten: List[DogAllOfFoodEaten]):
"""Sets the food_eaten of this Dog. :param food_eaten: The food_eaten of this Dog. :type food_eaten: List[DogAllOfFoodEaten] """self._food_eaten=food_eaten
Why the first syntax break the imports ? Is the syntax wrong ?
When im using the second syntax, i dont understand why it is generating a DogAllOfFoodEaten.
VBA-N7
changed the title
[PYTHON]: Using allOf for inheritance generate bad imports
[PYTHON]: Bug or not bug ? Using allOf for inheritance generate bad imports
Jun 18, 2024
Hi,
I'm not sure what i will describe is a bug; I prefer to give you some clues and have a little chat before openning a bug.
Context:
I fetch a swagger generated from one of my colleagues who is using Swashbuckle and the inheritance for the Dog schema use the following syntax:
When generate python flask server, the imports are kinda broken.
docker run --rm -v "${PWD}:/local" openapitools/openapi-generator-cli:v7.6.0 generate -i /local/test.yaml -g python-flask -o /local/dist
I saw on swagger.io that the syntax of allOf should be the following one:
When i'm using this one, the imports are correct (working):
DogAllOfFoodEaten
.Actual:
Expected:
Thanks for all you have done so far. I really appreciate it.
Have a good day.
The text was updated successfully, but these errors were encountered: