referencing a json-schema from openapi3
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 35/100
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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...
- Ngôn ngữ chính
- Python
- Star
- 368
- Fork
- 140
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của python-openapi/openapi-core
-
kind/bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
python-openapi/openapi-core#1188 · 2 bình luận ·
-
kind/bug
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 68/100
python-openapi/openapi-core#1225 · 2 bình luận ·
-
kind/bug
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 76/100
python-openapi/openapi-core#1212 ·
-
[Bug]: Query parameter validation fails to match empty string when listed as a valid enum value Đang mởkind/bug
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 68/100
python-openapi/openapi-core#1210 ·
-
kind/bug kind/bug/confirmed
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 58/100
python-openapi/openapi-core#1180 · 3 bình luận ·
Tất cả issue của python-openapi/openapi-core
Issue tương tự
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 90/100
learningequality/ricecooker#747 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
BSData/horus-heresy-3rd-edition#3171 ·
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
run-llama/llama_index#23199 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
KhronosGroup/glTF-Blender-IO#2769 ·