referencing a json-schema from openapi3
還沒有人認領這個 Issue。
評估
研究方向
Start with factories.py:SpecFactory:create and reproduce the failure using the provided test.yaml and test.json examples. Check how openapi_spec_validator handles the external $ref and review the linked OpenAPI Schema Object reference. Done means documenting or implementing the supported handling for this reference, including whether client-side validation can be bypassed.
由索引模型根據 Issue 內容生成。
描述
Hello,
I am currently in the process of creating a python based REST api. I wrote an openapi 3.0 interface that reference an external json-schema file using $ref: 'test.json' (openapiref)[https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md#schemaObject] as I thought this is supposed to be possible.
Now I wanted to use openapi-core to validate requests and responses but I hit a problem which is that the validation of my openapi interface file does not go through because I get an error of type:
{'description': 'some external json', 'content': {'application/json': {'schema': {'$ref': './test.json', 'x-scope': ['file:///c:/Users/anderegg/Documents/dev/OSPARC/jsonschematest/testapi.yaml']}}}}
is not valid under any of the given schemas
Failed validating 'oneOf' in schema['properties']['paths']['patternProperties']['^/']['properties']['get']['properties']['responses']['properties']['default']:
{'oneOf': [{'$ref': '#/definitions/response'},
{'$ref': '#/definitions/reference'}]}
On instance['paths']['/']['get']['responses']['default']:
{'content': {'application/json': {'schema': {'$ref': './test.json',
'x-scope': ['file:///c:/Users/anderegg/Documents/dev/OSPARC/jsonschematest/testapi.yaml']}}},
'description': 'some external json'}
my example openapi interface looks like this:
# test.yaml
openapi: "3.0.0"
info:
description: This is a test api
version: 1.0.0
title: Test API
paths:
/:
get:
tags:
- users
summary: Returns a nice greeting
description: Returns a nice greeting
operationId: root_get
responses:
default:
description: some external json
content:
application/json:
schema:
$ref: './test.json'
and my example json-schema:
// test.json
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "Test",
"type": ["string", "null"],
"format": "date-time"
}
Now I understand the problem comes from factories.py:SpecFactory:create where openapi_spec_validator is failing in validating my file because the ref does not follow #/something.
Am I wrong in thinking I can direclty reference a JSON schema?
If not, is it possible to disable the spec validation from client side? Or should I change something in the way I reference it?
Thanks for any input on this...
- 主要語言
- Python
- 星號
- 368
- 分支
- 140
- PR 合併指標
- 30 天內沒有已合併 PR
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
python-openapi/openapi-core 的其他 Issue
-
kind/bug
難度 2/5 1-3 小時 新手友好度 68/100
python-openapi/openapi-core#1188 · 2 則留言 ·
-
kind/bug
難度 3/5 1-2 天 新手友好度 68/100
python-openapi/openapi-core#1225 · 2 則留言 ·
-
kind/bug
難度 3/5 1-2 天 新手友好度 76/100
python-openapi/openapi-core#1212 ·
-
kind/bug
難度 3/5 1-2 天 新手友好度 68/100
python-openapi/openapi-core#1210 ·
-
kind/bug kind/bug/confirmed
難度 3/5 1-2 天 新手友好度 58/100
python-openapi/openapi-core#1180 · 3 則留言 ·
查看 python-openapi/openapi-core 的全部 Issue
相似的 Issue
-
enhancement
難度 2/5 1-3 小時 新手友好度 70/100
canonical/paas-charm#368 · 1 則留言 ·
-
難度 2/5 1-3 小時 新手友好度 75/100
-
tech debt
難度 2/5 1-3 小時 新手友好度 75/100
-
難度 1/5 1 小時以內 新手友好度 90/100
StevenBlack/hosts#3256 ·
-
難度 1/5 1 小時以內 新手友好度 90/100
qualcomm/qai-appbuilder#275 ·