use of $ref in paths parameters errors for "in: path" parameters
See original GitHub issueAn error message is currently generated when using $ref for in: path (in: query and in: body work fine) parameters from within the paths description, e.g. - $ref: ‘#/parameters/tag-name’, where tag-name appears in the path, e.g. /tags/{tag-name}:
Q | A |
---|---|
Bug or feature request? | Bug |
Which Swagger/OpenAPI version? | swagger 2.0 |
Which Swagger-Editor version? | http://editor.swagger.io/ (but not http://editor2.swagger.io) |
How did you install Swagger-Editor? | online editor |
Which browser & version? | Tried Chrome and Firefox, same error in both cases |
Which operating system? | Windows |
Example extracted from the Instagram API example file:
swagger: '2.0'
info:
version: v1
title: Instagram API
host: api.instagram.com
basePath: /v1
schemes:
- https
produces:
- application/json
consumes:
- application/json
parameters:
tag-name:
name: tag-name
in: path
description: Tag name
type: string
required: true
paths:
/tags/{tag-name}:
parameters:
- $ref: '#/parameters/tag-name'
get:
description: Get information about a tag object.
responses:
200:
description: OK
schema:
$ref: '#/definitions/Tag'
definitions:
Tag:
type: object
properties:
media_count:
type: integer
name:
type: string
This results in the following error:
Semantic error at paths./tags/{tag-name} Declared path parameter “tag-name” needs to be defined as a path parameter at either the path or operation level Jump to line 23
However, the UI recognises what the tag-name is and allows the “Try it out” operation to be performed
To avoid the error, the parameter definition can be brought in-line (see below), but this is undesirable if many operations reference the same parameter.
paths:
/tags/{tag-name}:
parameters:
- name: tag-name
in: path
description: Tag name
type: string
required: true
Issue Analytics
- State:
- Created 6 years ago
- Reactions:7
- Comments:11 (4 by maintainers)
Thanks for the issue references - I’d only searched on open issues when raising this, but thankfully raising this separately has turned out to be appropriate
Will do. Just wanted to be sure I wasn’t doing something wrong, first.