Unable to use $ref in path parameters
Closed this issue · 4 comments
Using $ref
in path parameters breaks
Here's a test case:
# YAML definition
swagger: '2.0'
info:
version: "1.0.0"
title: petstore
parameters:
productId:
name: productId
in: path
type: string
required: true
paths:
/users/{productId}/:
get:
parameters:
-
$ref: '#/parameters/productId'
responses:
"200":
description: Describe the 200 response in more detail
A cursory glance at specs.js
suggests that this is because parameters are iterated over, but not "resolved", so if a parameter is a reference, it is ignored (because it doesn't look like a path parameter):
Here for path-level parameters: https://github.com/apigee-127/swagger-tools/blob/master/lib/specs.js#L1064-L1075
Here for method-level parameters: https://github.com/apigee-127/swagger-tools/blob/master/lib/specs.js#L1104-L1114
This causes an issue down the road when sParams
is compared to the params in the path itself, because those paths haven't been added to sParams
:
https://github.com/apigee-127/swagger-tools/blob/master/lib/specs.js#L1136-L1141
I'll be committing a fix for this shortly. The work is done but tests are being written to prove refs in all places are supported.
Nice, thanks! Is this somewhere on a separate branch I could pull to work with in the meantime? I'll be sure to report issues if I find any.
+1
This should be resolved now.