-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
JSON References resolve base path - version 3 #1409
Comments
Can you share a full definition? |
A.yaml (The main file, it's accessible by http://myhost.com/A.yaml)
B.yaml (in the same directory, http://myhost.com/B.yaml)
I got error:
If I replace the |
+1 I'm having the same issue. It would be nice to be able to set 'Pointer Resolution Base Path' in version 3. |
I don't see the behavior of this being changed soon. The editor works locally and has no knowledge of where the file is hosted. |
@webron that's exactly the reason the 2.x release had the useful option |
I understand, but in terms of priorities, it's not at the top. We'll gladly review PRs though. |
In the mean time, is there a workaround? can I hard code the |
My workaround has been to use the docker image swaggerapi/swagger.io-editor, which allows you to revert to the 2.x interface and use the old preference settings. EDIT: Just noticed that the link simply takes you to the hosted version on swagger.io, so if you're trying to do only local work that won't help you. |
Ouch! I this effectively means I can't use version 3 for big projects where things need to be organized into multiple files for clarity. |
@joshmaker My current workaround.. https://github.com/moon0326/swagger-ui-watcher works fine with local relative path without base path. It now supports OpenAPI as well. |
thx |
I need to rollback but I cant find version 2.x of swagger-editor-dist. |
+1 for a resolution to this issue. It prevents using v3 of the editor for larger projects. |
+1 - this is kind of a big deal to me as well |
+1 same for me, our team is fine with the portability of the online editor, but we're still forced to use v2 editor because of this... |
Same for me, I need relative paths in documents because there's distinct enviroments hosting Swagger-editor (i.e., distinct URLs). |
+1 for a fix of this issue.Without references to local schema files we need to look around for another tool :( |
+1 - V2 only viable option for real world API development that leverages common schema definitions in separate file(s). Very disappointing. |
+1 would love to use it as well. |
Could you update what's the status of this PR? We externalized definitions in yams files, and couldn't reference them in any swagger-editor V 3 (the latest tried 3..5.1) using relative paths that we are able to resolve in V 2 (e.g. $ref: './external.yaml#someDef'). It's a major roadblock for us to move to V 3 |
This is not a PR, it's a feature request. At the moment, we're not doing any active work on supporting it, but we might in the future. |
Thanks Ron. Would you be able to prioritize it? Based on the posting it is blocking many people working on real world enterprise implementations to move to V 3. |
Unfortunately, given the work load that we have - I can't prioritize it at the moment. I'm sure this is not what you'd want to hear, but there is a solution we provide as a company in our commercial tool (whether free or paid versions). This is not to say that that's the reason this is not being implemented here. The way it's implemented there is very different than what we could just migrate to the open source, otherwise we would have done it by now. We have limited resources and our to do list is (very) long - someone's going to not be happy with the results eventually. As stated above though, we'd review related PRs should anyone submit them. |
@jemerald wrote:
Thanks for that. It works well. Nice clean bit of code. To get it to work with my own files, I renamed your |
FWIW, we'd be happy to accept a PR to re-add the functionality. |
Good idea @CharlieReitzel , although the project is really just a demo on how to setup an local editor environment, and to demo that the editor actually do support JSON references across files (which is what the OP is about). Feel free to adopt it for your needs. 😃 |
It seems that activity in the open issue has stopped. Has any progress been made on this issue to support a relative schema? As many have mentioned, this is a significant blocker for adopting v3 of the OpenAPI specifications. The official swagger specifications seem to allow the referencing of components from external files: |
I'm now successfully using swagger-ui-watcher for this. :) |
Hi, I don't know if helps, but i resolved this issue by doing this changes:
swagger-editor:
image: swaggerapi/swagger-editor
container_name: "swagger-editor"
ports:
- "8081:8080"
volumes:
- ./docker/swagger:/usr/share/nginx/html/docs
environment:
URL: /docs/main.yml
openapi: 3.0.0
info:
title: Server API
description: API Documentation for Server.
version: 1.0.0
servers:
- url: 'http://localhost:8000/api/v1/'
description: Local Server
- url: 'http://staging.server.com/api/v1'
description: Staging Server
paths:
/login:
$ref: 'session.yml#/login'
login:
post:
summary: Authenticate User
description: Authenticate User
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/User'
components:
schemas:
User:
type: object
properties:
id:
type: integer
readOnly: true
example: 1
email:
description: User Email
type: string
format: email
example: example@mail.com
password:
type: string
writeOnly: true
example: 1
required:
- email
- password url that i use to go directly to the main.yml: http://localhost:8081/?url=/docs/main.yml |
I receive the same error when I try to reference another file:
I tried everything I found on internet but could not get it working. |
This is very useful, after installation according to the README.MD, you just need to run |
It's still doesn't work. |
I'm commenting because this is the first thing that pops up when I Google "Tried to resolve a relative URL, without having a basePath." and I think it deserves a clear summary. There are two problems being discussed in this issue:
@jemerald provided a great answer to 1 here! The answer to 2 is no, this is an open feature request. I suggest that this issue be closed since Problem 1 has been resolved. Then someone can open up a new issue specifically re Problem 2 without all the noise surrounding Problem 1. If I misunderstood what's going on here, let me know and I will delete/edit this comment! |
@tgiardina wrote:
Defintely helpful.
I'd suggest a 3rd issue: relative URLs should "just work" relative to the primary document as described here: It's should not be necessary to host swagger-editor in a Node server to make this work. Javascript is fully capable of resolving relative URLs. |
Well, thing is, there was an issue on swagger-ui, there swagger-api/swagger-ui#2746, it was closed and locked with a simple message saying "this was fixed" but, well, it is three and a half years after the "this was fixed" message, and I spent about an hour trying to figure out how it was fixed, like, going through all the commits between the issue being created and the "it was fixed" message, in multiple swagger-* repositories, and well, it seems it is not fixed. |
I resolved the issue in by resolved references ($ref) in spec first before provide it to Swagger-UI. Here is the repo shows how to do it - https://github.com/chuve/swagger-multi-file-spec |
Years later, this still remains an open issue! |
Resolved n close it |
@prashantnirgun then can we close this issue? This actual issue is not yet closed, and there is no documented solution that I have found; I just encountered this issue yesterday when using the editor.swagger.io service |
Any news regarding solving this issue? I'm having the same problem 6 years later. |
Check the comment above - #1409 (comment) |
I was able to use Solve it by using the swagger-cli and bundle the main file to resolve the $refs as following: |
I want to try to add some visibility to @jemerald's awesome comment from 2019. Swagger Editor is actually capable of doing this! You have to point the editor at your openapi file by adding a |
With version 3 of the editor, it does not resolve relative references.
Version 2 seems to have it fixed.
#1000
Version 2 of the editor has a preference panel, where the 'Pointer Resolution Base Path' can be set. How this can be done in Version 3?
Could not resolve reference because of: Tried to resolve a relative URL, without having a basePath. path: './Clinic.yaml' basePath: 'undefined'
Jump to line 59
The text was updated successfully, but these errors were encountered: