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

Won't generate client for JSON formatted API with tabs #924

Open
derenrich opened this issue Jan 2, 2024 · 3 comments
Open

Won't generate client for JSON formatted API with tabs #924

derenrich opened this issue Jan 2, 2024 · 3 comments

Comments

@derenrich
Copy link

derenrich commented Jan 2, 2024

Describe the bug

Running

openapi-python-client generate --url https://raw.githubusercontent.com/wikimedia/mediawiki-extensions-Wikibase/e45d4f725e25a95ec2b034238fd3736f19053a16/repo/rest-api/specs/openapi.json

gives me the error

Error(s) encountered while generating, client was not created

Invalid YAML from provided source: while scanning for the next token
found character '\t' that cannot start any token
  in "<byte string>", line 2, column 1:
        "openapi": "3.1.0",
    ^

This is a follow-on to this old bug #488 which got fixed in b01db03 . It appears the fix doesn't quite work because github doesn't serve JSON files with the expected content-type (curl with -v gives me "< content-type: text/plain; charset=utf-8").

OpenAPI Spec File
I was trying to generate a client for this code

Desktop (please complete the following information):

  • OS: Ubuntu 20.04.6 LTS running under Windows 11
  • Python Version: 3.8.0
  • openapi-python-client version 0.17.0

Additional context
I think the correct fix ought to be to fall back to JSON parsing in the event of YAML parsing failure (or else a flag to specify?). I'm not sure why the mimetype isn't being guessed right

@derenrich
Copy link
Author

derenrich commented Jan 2, 2024

I got it to work by downloading a local copy and then running a bundler to condense it into a single file (unsure if support for that is intended). It runs but produces this warning and does nothing useful

Warning(s) encountered while generating. Client was generated, but some pieces may be missing

WARNING parsing GET /entities/items/{item_id} within items. Endpoint will not be generated.

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

Parameter(name='If-None-Match', param_in=<ParameterLocation.HEADER: 'header'>, description=None, required=False, deprecated=False, allowEmptyValue=False, style=None, explode=False, allowReserved=False, param_schema=Schema(title=None, multipleOf=None, maximum=None, exclusiveMaximum=None, minimum=None, exclusiveMinimum=None, maxLength=None, minLength=None, pattern=None, maxItems=None, minItems=None, uniqueItems=None, maxProperties=None, minProperties=None, required=None, enum=None, const=None, type=<DataType.ARRAY: 'array'>, allOf=[], oneOf=[], anyOf=[], schema_not=None, items=Schema(title=None, multipleOf=None, maximum=None, exclusiveMaximum=None, minimum=None, exclusiveMinimum=None, maxLength=None, minLength=None, pattern='^(?:".+"|\\*)$', maxItems=None, minItems=None, uniqueItems=None, maxProperties=None, minProperties=None, required=None, enum=None, const=None, type=<DataType.STRING: 'string'>, allOf=[], oneOf=[], anyOf=[], schema_not=None, items=None, properties=None, additionalProperties=None, description=None, schema_format=None, default=None, nullable=False, discriminator=None, readOnly=None, writeOnly=None, xml=None, externalDocs=None, example=None, deprecated=None), properties=None, additionalProperties=None, description=None, schema_format=None, default=None, nullable=False, discriminator=None, readOnly=None, writeOnly=None, xml=None, externalDocs=None, example=None, deprecated=None), example=None, examples=None, content=None)

for every endpoint so it seems to be mad still. I'll poke around and maybe file another ticket.

@derenrich
Copy link
Author

I was able to work around the issue and got the generated library working. Thanks for this tool!

@derenrich
Copy link
Author

Actually looking further it seems that the generated code is always setting the parsed response to None. very strange

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant