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

Operation parameter is $ref #621

Closed
ruhley opened this issue Sep 29, 2014 · 10 comments
Closed

Operation parameter is $ref #621

ruhley opened this issue Sep 29, 2014 · 10 comments
Milestone

Comments

@ruhley
Copy link

ruhley commented Sep 29, 2014

I have some parameters defined in the base swagger json object.

"swagger": "2.0",
"basePath": "/docs"
"parameters": {
    "id": {
        "name": "id",
        "in": "path",
        "description": "Id of the item to get",
        "type":  "number",
        "required": true,
    }
}

And I want to reference it in lots of operations as documented at https://github.com/wordnik/swagger-spec/blob/master/versions/2.0.md#operationObject

Here is my fix in swagger-client.js

At line 428 I added

if (param['$ref']) {
      param = parent.parameters[param['$ref']];
      this.parameters[i] = param;
    }

And to be able to point to parent.parameters I added at line 280

this.parameters = response.parameters || [];
@gyllen
Copy link

gyllen commented Oct 8, 2014

+1 on this one

@DavidBiesack
Copy link

I'm not sure why this is tagged as a feature and not as a bug. The spec says for a Operation Object

parameters :
[Parameter Object | Reference Object]

The list can use the Reference Object to link to parameters that are defined at the Swagger Object's parameters.

See also the related closed issues, swagger-api/swagger-editor#182
and apigee-127/swagger-tools#79 which claimed to fix $ref for parameters long ago.

@webron
Copy link
Contributor

webron commented Jan 8, 2015

Because support for 2.0 is not yet officially released, and that's one of the features that need to be supported.

@tarlog
Copy link

tarlog commented Jan 27, 2015

+1

@calfzhou
Copy link

+1 really need this. since i have lots of common parameters, i use $ref frequently in operation object.

@fehguy
Copy link
Contributor

fehguy commented Jan 28, 2015

we're getting there, please keep tracking this issue for the fix, which will be in swagger-ui-2.1.0-M2

@duncanhall
Copy link

For anyone that's still affected by this, I've made a simple tool that will work around this until it's resolved: https://github.com/duncanhall/expand-swagger-refs/

It takes a swagger schema as an input and outputs the same schema with $ref values manually expanded.

@webron
Copy link
Contributor

webron commented Feb 5, 2015

👍

@ShaneDelmore
Copy link

@duncanhall Thanks for the expand script. Gets me by just fine until it is added to master.

@fehguy
Copy link
Contributor

fehguy commented Feb 22, 2015

addressed in 21d8a89

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants