Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Different $ref path resolving in flatten and validate mode #2469

Open
SergeAx opened this issue Jan 2, 2021 · 5 comments
Open

Different $ref path resolving in flatten and validate mode #2469

SergeAx opened this issue Jan 2, 2021 · 5 comments
Assignees
Labels
needs testing Needs more testing for issue confirmation/qualification Ref resolution windows

Comments

@SergeAx
Copy link

SergeAx commented Jan 2, 2021

Problem statement

go-swagger handles $ref paths differently in flatten and validate mode.

Swagger specification

test-spec.zip

Environment

swagger version: 0.25.0
go version: 1.14.2
OS: Windows

Steps to reproduce

I am using recommended docker mode to run go-swagger, setting concrete version 0.25.0 (see swagger.cmd) via cmd file.

I have my spec divided into files for every path and every model, in paths and models subdirectories respectively. I also have a root file swagger.yaml to bring all the paths together and another file pathParams.yaml to reuse RESTful path parameters for all types of items IDs.

All those files are located in swagger subdirectory of my project. If I try to validate my spec, I got:

C:\Users\Me\app\swagger>swagger validate swagger.yaml

The swagger spec at "swagger.yaml" is invalid against swagger specification 2.0.
See errors below:
- some references could not be resolved in spec. First found: open /app/swagger/paths/models/Error.yaml: no such file or directory

If I generate flattened json spec, it generates and validates correctly:

C:\Users\Me\app\swagger>swagger flatten swagger.yaml -o swagger.json
<no output, file is created>

C:\Users\Me\app\swagger>swagger validate swagger.json
2021/01/02 21:19:12
The swagger spec at "swagger.json" is valid against swagger specification 2.0

So it seems to me that go-swagger handles $ref paths differently in flatten and validate modes. I want to validate my spec as a part of CI pipeline and don't want to generate extra artifacts.

Moreover, when I try to use github.com/go-openapi/validate package to validate my app output against the spec - I got the "file not found" error while calling loads.Spec() / analysis.Flatten(). I hope solving that problem by understanding roots of this issue.

@bharatlakhiyani
Copy link

Any update/solution on this?

@fredbi fredbi self-assigned this Feb 7, 2021
@fredbi fredbi added the needs testing Needs more testing for issue confirmation/qualification label Feb 7, 2021
@fredbi
Copy link
Contributor

fredbi commented Feb 8, 2021

@SergeAx @bharatlakhiyani

The behavior is correct on Linux: neither validate nor flatten wants to proceed through the invalid $ref.
It looks to me that you hit a Windows-specific issue. This particular one I did not know about, though.

I've updated our current master with a bunch of Windows-specific fixes over the last weekend.
There are still some windows issues with flatten, but I have certainly narrowed down the scope for them.

Would you please give it a shot?

@fredbi fredbi added the windows label Feb 8, 2021
@SergeAx
Copy link
Author

SergeAx commented Feb 16, 2021

@fredbi can I use Docker image quay.io/goswagger/swagger:dev, or should I build image myself from master?

@fredbi
Copy link
Contributor

fredbi commented Feb 16, 2021

@SergeAx the dev tag takes latest master. So yes, this onboards latest fixes specifically for windows. I hope this would work for you.

@bharatlakhiyani
Copy link

@fredbi

It's still not working. I am using it on mac

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs testing Needs more testing for issue confirmation/qualification Ref resolution windows
Projects
None yet
Development

No branches or pull requests

3 participants