Support inline allOf enum #827
skpn
started this conversation in
Feature request
Replies: 2 comments
-
I have the same problem with the latest {
"openapi": "3.0.2",
"info": {
"title": "Example JSON API",
"version": "0.2.1",
"description": ""
},
"paths": {
"/api/foo/bar": {
"post": {
"operationId": "foo_bar",
"summary": " ",
"parameters": [
{
"in": "query",
"name": "item",
"schema": {
"title": "Item",
"type": "string"
},
"required": true
},
{
"in": "query",
"name": "operation_type",
"schema": {
"default": "aa",
"allOf": [
{
"title": "OperationType",
"description": "An enumeration.",
"enum": [
"aa",
"bb",
"cc"
],
"type": "string"
}
]
},
"required": false
}
],
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"title": "Response",
"type": "string"
}
}
}
}
}
}
}
},
"components": {
"schemas": {}
}
} And here is the generated code: from typing import Any, Dict, List, Type, TypeVar
import attr
T = TypeVar("T", bound="FooBarOperationType")
@attr.s(auto_attribs=True)
class FooBarOperationType:
""" """
additional_properties: Dict[str, Any] = attr.ib(init=False, factory=dict)
def to_dict(self) -> Dict[str, Any]:
field_dict: Dict[str, Any] = {}
field_dict.update(self.additional_properties)
field_dict.update({})
return field_dict
@classmethod
def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T:
d = src_dict.copy()
foo_bar_operation_type = cls()
foo_bar_operation_type.additional_properties = d
return foo_bar_operation_type
@property
def additional_keys(self) -> List[str]:
return list(self.additional_properties.keys())
def __getitem__(self, key: str) -> Any:
return self.additional_properties[key]
def __setitem__(self, key: str, value: Any) -> None:
self.additional_properties[key] = value
def __delitem__(self, key: str) -> None:
del self.additional_properties[key]
def __contains__(self, key: str) -> bool:
return key in self.additional_properties Note that the |
Beta Was this translation helpful? Give feedback.
0 replies
-
Not sure if the first example was the same (URL doesn't go anywhere for me) but for the second one, it seems the problem is we don't support inline allOf an enum right now, only references. I'll adjust the issue title accordingly. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Describe the bug
In my openapi.json, a parameter for one of my schemas has a string enum as its type, and a member of that enum as its default value.
In the generated client it has type Union[Unset, None] and default value UNSET.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
In the generated client, the schema's parameter should have type Union[Unset, MyEnum] and default value MyEnum.VALUE like in the openapi.json
OpenAPI Spec File
http://sandbox.platform.recital.ai:8000/api/v1/openapi.json
Desktop (please complete the following information):
Beta Was this translation helpful? Give feedback.
All reactions