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

RESPONSE refs can not be internal references. Why? #1388

Closed
ChrisTitos opened this issue Aug 23, 2015 · 6 comments
Closed

RESPONSE refs can not be internal references. Why? #1388

ChrisTitos opened this issue Aug 23, 2015 · 6 comments

Comments

@ChrisTitos
Copy link

Hi,

I'm having troubles using the latest swagger-codegen. I get this error:

RESPONSE refs can not be internal references 
(through reference chain: io.swagger.models.RefResponse["$ref"]) 
(through reference chain: io.swagger.models.Path["get"]->io.swagger.models.Operation["responses"]->java.util.LinkedHashMap["404"]) 
(through reference chain: io.swagger.models.Swagger["paths"]->java.util.LinkedHashMap["/companies/{id}"])

This exception is thrown by swagger-core here:
https://github.com/swagger-api/swagger-core/blob/master/modules/swagger-models/src/main/java/io/swagger/models/refs/GenericRef.java#L37

In the comment it says "PATH AND RESPONSE refs can only be URL or RELATIVE", but my question is, where does it say this in the spec? The Responses object doesn't mention any limitations to a reference object.

I might be missing something, but this exception confused me (especially because the online codegen doesn't complain)

@webron
Copy link
Contributor

webron commented Aug 23, 2015

When you say latest swagger-codegen, do you mean the master branch or develop_2.0?

@ChrisTitos
Copy link
Author

At first I thought it was both master and develop, but after doing a clean first, now it only happens in develop_2.0.
I also get the exception when using swagger-parser v1.0.10

@ChrisTitos
Copy link
Author

The develop_2.0 branch has been merged into codegen master, so now I also get the exception when using the master branch.
But like I said, this exception shouldn't even be there right? The spec says nothing about what kind of reference is allowed or not (or am I misinterpreting something?).

@ePaul
Copy link
Contributor

ePaul commented Aug 26, 2015

This error message seems to have been introduced in #1271 (commit 59e6b10).
I didn't find any justification for this in the discussion of the Pull request, nor in the commit comment (which doesn't say much at all).

ePaul added a commit to ePaul/swagger-core that referenced this issue Aug 27, 2015
This commit does those things:

* move the internal prefixes into the RefType enum (→ RefConstants class is not needed anymore)
* add prefixes for RESPONSE and PATH
* get rid of the exception when trying to use an internal reference of type RESPONSE or PATH
* add test cases in GenericRefTest for PATH and RESPONSE.
@ePaul
Copy link
Contributor

ePaul commented Sep 11, 2015

Related to this, there seems to be no responses property of the Swagger object. Maybe this was the reason?

@fehguy
Copy link
Contributor

fehguy commented Oct 19, 2015

this has been added and will be available in 1.5.4

@fehguy fehguy closed this as completed Oct 19, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants