flasgger / flasgger

Easy OpenAPI specs and Swagger UI for your Flask API

Home Page:http://flasgger.pythonanywhere.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unable to use import in yaml definitions with relative path

aokros opened this issue · comments

Hi,
I'm having trouble using the import: "some.yaml" function in yaml files. I'm using a setup where the API descriptions are in separate files and I use Blueprints to define the API itself. I'd like to remove a lot of redundancy in parameters by using $ref and it would be great to use the import option in the yaml files so I can easily reference the parameters, allowed values across the API.
After a lot of debugging I ended up with there must be some issues around how root_path is used when reading the yaml files and attempting to parse and include the imported yamls.

I ended up changing this line to use the obj.root_path whenever exists and fallback to the get_root_path function if it does not. With this change now I can successfully import yamls files by using relative paths.

root_path = get_root_path(obj)

Do you think it makes sense to add this change to the code, or there is a well-known reason behind the current implementation? Alternatively I might miss some configuration that would solve this issue instantly...

Thanks a lot!

--Attila