Open maddin1991 opened 7 months ago
I'm having the same issue after breaking out my schemas, parameters, and paths into their own subdirectories in an effort to organize a large yaml. I discovered that this is working fine in connexion 3.0.2.
If I downgrade to connexion 3.0.2, all is well. Looks like 3.0.3 and above include the breaking change.
@eharvey71 are you on Windows as well?
If I downgrade to connexion 3.0.2, all is well. Looks like 3.0.3 and above include the breaking change.
I don't immediately see any relevant changes in 3.0.3
I’m still investigating. The first time it broke, I was on windows. It worked on MacOS for me but I was on 3.0.2. Once I installed 3.0.5, it broke on MacOS. Either way, no dice on Windows 10. I’ve been through every module, hoping to prove helpful.
On Tue, Feb 13, 2024 at 4:58 PM Robbe Sneyders @.***> wrote:
@eharvey71 https://github.com/eharvey71 are you on Windows as well?
If I downgrade to connexion 3.0.2, all is well. Looks like 3.0.3 and above include the breaking change.
I don't immediately see any relevant changes in 3.0.3
— Reply to this email directly, view it on GitHub https://github.com/spec-first/connexion/issues/1861#issuecomment-1942707023, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAH6LDYNXMPNI2KCDNMWZ43YTPOZNAVCNFSM6AAAAABCXZ7H2CVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNBSG4YDOMBSGM . You are receiving this because you were mentioned.Message ID: @.***>
Maybe there is something broken with the jsonschema library. This worked for me as a temporary fix:
from pathlib import Path
import yaml
import connexion.json_schema
from connexion.json_schema import ExtendedSafeLoader
class CustomFileHandler:
"""Handler to resolve file refs."""
def __call__(self, uri):
path = Path("your_corret_path_to_spec").resolve()
with open(path) as fh:
return yaml.load(fh, ExtendedSafeLoader)
connexion.json_schema.handlers.update(
{
"file": CustomFileHandler(),
"": CustomFileHandler(),
}
)
This is an elegant solution and thank you. I have my yml files divided into subdirectories for paths, parameters, schemas, etc... In my configuration, I'm initializing my app like this:
basedir = pathlib.Path(__file__).parent.resolve()
swagoptions = SwaggerUIOptions(swagger_ui = True, swagger_ui_template_dir = basedir / 'swagger-ui')
connex_app = FlaskApp(__name__, specification_dir=basedir / "apispecs")
I can create the utility class and leverage my basedir in all of this, but I'm getting errors at startup:
jsonschema.exceptions._RefResolutionError: [Errno 21] Is a directory
Paths are like this to specs, where my swagger.yml refers to the proper paths:
project/
│── apispecs/
|── swagger.yml
|── parameters/
|── _index.html
│── securitySchemas/
|── _index.html
│── schemas/
|── _index.html
swagger.yml sample:
components:
schemas:
$ref: "./schemas/_index.yml"
parameters:
$ref: "./parameters/_index.yml"
securitySchemes:
$ref: "./security/_index.yml"
I would think this solution would be looking at the file associated with each $ref. Not sure why that's happening but I'll keep at it.
New issue opened: #1909
I'm no longer having this issue with 3.1
Description
I'm getting this error when i use local references to a spec file in the same folder:
_RefResolutionError: [Errno 2] No such file or directory: '\\\\\\schemas.json'
My OS is windows10/11. I did not test it on linux.
Steps to reproduce
This is my specification:
And this is my schemas.json file:
Additional info:
Output of the commands:
Python 3.11.7
connexion 3.0.5