How to build a registry from a simple OpenAPI document dict?
まだ誰も着手していません。
評価
調査の方向性
issue にある Registry().with_resources、Resource.from_contents、Draft202012Validator(registry=registry, schema=schema) の例から始めてください。OpenAPI の components/schemas エントリを、失敗している JSON-pointer lookup と比較し、registry の構築について referencing のドキュメントを確認してください。OpenAPI 辞書を登録でき、検証で表示された KeyError が発生しなくなれば完了です。
索引モデルが issue の本文から書いたものです。
説明
I'm trying to build a registry
self.registry = Registry().with_resources(
(f"#/components/schemas/{k}", Resource.from_contents(v, referencing.jsonschema.DRAFT202012)
for k, v in openapi["components"]["schemas"].items()
)
but then it fails during validation
jsonschema.Draft202012Validator(registry=registry, schema=schema).validate(dict)
with
self = Resource(contents={'oneOf': [{'type': 'object', 'properties': {'status': {'enum': [200]}, 'headers': {'type': 'object'...['mime', 'body']}]}}, 'required': ['status', 'headers', 'body']}]}, _specification=<Specification name='draft2020-12'>)
pointer = '/components/schemas/YtDlInfo'
resolver = Resolver(_base_uri='', _registry=<Registry (25 resources, 5 uncrawled)>)
def pointer(self, pointer: str, resolver: Resolver[D]) -> Resolved[D]:
"""
Resolve the given JSON pointer.
Raises:
`exceptions.PointerToNowhere`
if the pointer points to a location not present in the document
"""
if not pointer:
return Resolved(contents=self.contents, resolver=resolver)
contents = self.contents
segments: list[int | str] = []
for segment in unquote(pointer[1:]).split("/"):
if isinstance(contents, Sequence):
segment = int(segment)
else:
segment = segment.replace("~1", "/").replace("~0", "~")
try:
> contents = contents[segment] # type: ignore[reportUnknownArgumentType]
E KeyError: 'components'
how do I correctly build a registry from an OpenAPI dict? Docs don't mention this
Thanks
- 主要言語
- Python
- スター
- 53
- フォーク
- 27
- 平均マージ
- 1日 8時間
- マージ済み PR(30日)
- 8
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
python-jsonschema/referencing のほかの issue
-
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
python-jsonschema/referencing#366 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
python-jsonschema/referencing#257 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 20/100
python-jsonschema/referencing#226 · コメント 1 件 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 52/100
python-jsonschema/referencing#178 · コメント 6 件 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 30/100
python-jsonschema/referencing#119 · コメント 4 件 ·
python-jsonschema/referencing の issue をすべて見る
似ている issue
-
bug priority:low
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
CyberAgent/psd2svg#436 ·
-
area/install-update comp/cli comp/desktop P3 sweeper:risk-compatibility type/bug
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
NousResearch/hermes-agent#122386 · コメント 1 件 ·
-
ai-generated
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
vllm-project/production-stack#1105 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100