parameter fails to validate when specified as a $ref
See original GitHub issueParameters specified as a $ref are not validated
Here is an example
Define the following parameter under components.parameters
components:
parameters:
id:
name: id
in: path
description: ID of pet to fetch
required: true
schema:
type: integer
format: int64
Use the parameter in a route:
paths:
/pets/{id}:
get:
description: Returns a user based on a single ID, if the user does not have access to the pet
operationId: find pet by id
parameters:
- $ref: '#/components/parameters/id'
The component #/components/parameters/id'
is not validated. It works if the component is placed inline without using a ref. This is not desirable given parameters may be specified generally as a ref
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Resolve the "Parameter validation failed" error in AWS ...
You can receive this error when you use an AWS-specific parameter: To pass a value that doesn't exist in the AWS Region or...
Read more >[BUG] $ref to common parameter not being resolved #1714
Description. Validation is failing to resolve a $ref in the parameter list to a common parameter defined outside the operation.
Read more >Validating parameters (“input rules”)
Input rules define whether or not parameters are required, and their maximum allowed length, for requests that match: Host: field in the HTTP...
Read more >What is wrong with Parameter validation failed. It is not ...
Parameter validation failed. It is not possible to provide valid values for all parameters. (rsParameterError).
Read more >Parameter validation failed: parameter value for parameter ...
The Subnets Parameter in your template has a type List<AWS::EC2::Subnet::Id> , which requires a reference to a list of valid Subnet IDs. The...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I had assumed there was a centralized $ref parser in action somewhere. After finding a series of commits that enabled $ref in response bodies (I think it was) I’ve decided that I’m not the right person to poke this particular $ref bug. For the future reader, I’ve switched to pre-parsing my schema doc with json-schema-ref-parser and then passing that to express-openapi. It seems to work well for me so far. Cheers.
I think this is another case of this kind of error, since @jberger said that is a centralized error.
If I try to validate a body with the key
name
it fails becauseadditionalProperties: false
. But if I don’t sendname
, it fails because it’s required.I guess that is because is reading only in his schema level, and is not recursive the validation.
But the schema is well formed, in the Swagger UI you can see it full.