Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Union[Unset, datetime.date] is not allowed in header #881

Open
beddows opened this issue Oct 21, 2023 · 1 comment
Open

Union[Unset, datetime.date] is not allowed in header #881

beddows opened this issue Oct 21, 2023 · 1 comment
Labels
🐞bug Something isn't working

Comments

@beddows
Copy link

beddows commented Oct 21, 2023

Describe the bug
The parameter name='IF-MODIFIED-SINCE' produces an error 'Union[Unset, datetime.date] is not allowed in header', which prevents the endpoint from being generated.

OpenAPI Spec File
https://docs.developers.clio.com/openapi.json

Desktop (please complete the following information):

  • OS: macOS 13.4.1
  • Python Version: 3.12
  • openapi-python-client version: 0.15.2

Additional context
The parameter schema is:
"schema": {
"type": "string", (the format in "YYYY-MM-DD")
"format": "date" (the format defined by full-date in RFC3339)
}
The client generator is attempting to map this schema to a Python Union type, the union of Unset and datetime.date, which is not allowed or fitting in a HTTP header. Maybe string dates need to be transformed to datetime objects and vice versa? Or the date could be converted to a string before setting the header? At least that's my limited understanding of the situation.

@dbanty dbanty added the 🐞bug Something isn't working label Nov 3, 2023
@derenrich
Copy link

I'm getting a similar issue with this https://raw.githubusercontent.com/wikimedia/mediawiki-extensions-Wikibase/e45d4f725e25a95ec2b034238fd3736f19053a16/repo/rest-api/specs/openapi.json (moving this comment from #924).

In this case it cries about:

Union[Unset, List[str]] is not allowed in header

where I'm assuming the issue is it doesn't understand how to map a list of strings to a string. Looking at the swagger endpoint for this API (https://doc.wikimedia.org/Wikibase/master/js/rest-api/#/items/getItem) it seems they want us to encode a list of strings as If-Match: "1276703231","1276705620"' . But I'm not sure if that's a standard openapi thing or if that's just some hack. If it's the latter it should probably have built in support.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants