openapi-generators / openapi-generators/openapi-python-client

Won't generate client for JSON formatted API with tabs

未关闭
#924 3 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

主要语言
Python
星标
2k
派生
293
平均合并
34 分钟
30 天内合并 PR
1

描述

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 https://github.com/openapi-generators/openapi-python-client/issues/488 which got fixed in https://github.com/openapi-generators/openapi-python-client/commit/b01db03349eb83e4c3ffdd1cc70f7eb2a9c6dae8 . 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

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

首先,使用链接的 OpenAPI JSON URL 重现报告的命令,并检查处理其 text/plain 响应的源加载和解析路径。当客户端能够从此 URL 成功生成,并且回退行为由回归测试覆盖时,即表示完成。

由索引模型根据 Issue 内容生成。

评估

技术栈
openapi, python
领域
devtools
Issue 类型
缺陷
难度
3/5
预计耗时
1-2 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。