This repository was archived by the owner on Dec 25, 2024. It is now read-only.
This repository was archived by the owner on Dec 25, 2024. It is now read-only.
[BUG] passing in model instance into __new__ raises error #81
Closed
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)?
- Have you tested with the latest master to confirm the issue still exists?
- Have you searched for related issues/PRs?
- What's the actual output vs expected output?
- [Optional] Sponsorship to speed up the bug fix or feature request
Copied issue from: OpenAPITools/openapi-generator#13997
per @Linux13524
Hi @spacether. I can reproduce the issue with the following spec:
openapi: 3.0.0
info:
version: 1.0.0
title: issue 13997 spec
license:
name: Apache-2.0
url: 'https://www.apache.org/licenses/LICENSE-2.0.html'
servers: []
tags: []
paths: {}
components:
schemas:
EventRequest:
type: object
required:
- event
properties:
event:
$ref: '#/components/schemas/Event'
Event:
type: object
properties:
name:
type: string
occuredAt:
type: string
properties:
type: object
I generated the client then similar how you did:
docker run --rm -v "${PWD}:/local" openapitools/openapi-generator-cli:v6.2.1 generate -i /local/openapi-test.yaml -g python -o /local/python_out/
Running the following does work:
>>> from openapi_client.model.event import Event
>>> from openapi_client.model.event_request import EventRequest
EventRequest(event=Event(name="test", properties={}))
But running this does not:
>>> from openapi_client.model.event import Event
>>> from openapi_client.model.event_request import EventRequest
>>> EventRequest(event=Event(name="test", properties={"name": "test"}))
Resulting in a similar error that @OmarBouslama reported:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/user/openapi/python_out/openapi_client/model/event_request.py", line 80, in __new__
return super().__new__(
File "/home/user/openapi/python_out/openapi_client/schemas.py", line 2439, in __new__
return super().__new__(cls, *args, **kwargs)
File "/home/user/openapi/python_out/openapi_client/schemas.py", line 532, in __new__
return __new_cls._get_new_instance_without_conversion_oapg(
File "/home/user/openapi/python_out/openapi_client/schemas.py", line 436, in _get_new_instance_without_conversion_oapg
properties = cls._get_properties_oapg(arg, path_to_item, path_to_schemas)
File "/home/user/openapi/python_out/openapi_client/schemas.py", line 1707, in _get_properties_oapg
new_value = property_cls._get_new_instance_without_conversion_oapg(
File "/home/user/openapi/python_out/openapi_client/schemas.py", line 436, in _get_new_instance_without_conversion_oapg
properties = cls._get_properties_oapg(arg, path_to_item, path_to_schemas)
File "/home/user/openapi/python_out/openapi_client/schemas.py", line 1707, in _get_properties_oapg
new_value = property_cls._get_new_instance_without_conversion_oapg(
File "/home/user/openapi/python_out/openapi_client/schemas.py", line 436, in _get_new_instance_without_conversion_oapg
properties = cls._get_properties_oapg(arg, path_to_item, path_to_schemas)
File "/home/user/openapi/python_out/openapi_client/schemas.py", line 1707, in _get_properties_oapg
new_value = property_cls._get_new_instance_without_conversion_oapg(
AttributeError: type object 'DynamicSchema' has no attribute '_get_new_instance_without_conversion_oapg'