Closed litteratum closed 3 months ago
Update: referencing paths also does not work:
paths:
/customer:
$ref: customer.yaml
I see "ValueError: unknown url type: 'customer.yaml'" from the tracelog.
Should it work or do I miss something?
You are missing spec_base_uri configuration to make referencing to work. It needs to be explicitly defined (version 0.19.3 will fix the problem).
import os
from openapi_core import Config, OpenAPI
SPEC_PATH = os.path.join(os.path.dirname(__file__), "api.yaml")
config = Config(spec_base_uri=f"file://{SPEC_PATH}")
OpenAPI.from_file_path(SPEC_PATH, config=config)
@p1c2u, thank you for your support. It indeed solved my issue!
Actual Behavior
I have the following paths:
The "response.json" schema exists on the same level as the "api.yaml".
Then I use
OpenAPI.from_file_path("apis/api.yaml")
. And it fails with:So for some reason, response schema resolution always fails...
Expected Behavior
I expect response schemas to be looked up relative to the API specification file. The same they are looked up for requests (and which works for me).
Steps to Reproduce
paths: /customer: post: responses: '200': description: OK content: application/json: schema: $ref: response.json
from openapi_core import OpenAPI
OpenAPI.from_file_path("api.yaml")