Schema Function Not Working with @key
See original GitHub issueDescribe the bug
The schema
function doesn’t appear to work when field
is '@key'
. Here’s the rule I’m trying to create:
response-code-type:
message: Response codes must be strings
recommended: true
given: $.paths.*.*.responses
then:
field: '@key'
function: schema
functionOptions:
schema:
type: string
To Reproduce
Given this OpenAPI document
openapi: 3.0.2
info:
title: Test Spec
version: 0.0.0
paths:
/foo:
get:
operationId: get-foo
responses:
200:
description: ''
Run this CLI command
spectral lint test-spec.yaml -r my-rules.yaml
Expected behavior
The lint output should contain the following:
9:17 warning response-code-type Response codes must be strings
It might be worth noting that if the rule is changed so that type
is number
or integer
, the rule is triggered.
Environment
- Library version: 4.2.0
- OS: Windows 10
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Mongoose Schema.method() is not working, and showing an ...
I run this code, it's working fine and am able to store encrypted password in this.encry_password property. But, the problem is that before ......
Read more >Mongoose v6.8.1: Schemas
If you want to add additional keys later, use the Schema#add method. ... method will not have access to the document and the...
Read more >Why does Mongoose remove the key when specified in the ...
When I specify the schema for an array of objects (may be doing this wrong), that particular key and all the data with...
Read more >Documentation: 15: 5.9. Schemas - PostgreSQL
When you run an ordinary query, a malicious user able to create objects in a schema of your search path can take control...
Read more >[Solved] DynamoDB Key element does not match the schema
it will fail because it does not have the "pk" attribute which is required. In case you're inserting an item with all 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 Free
Top 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
@dillonredding This one will be addressed as well, but in a slightly different manner. Spectral will warn you about property keys that are not JSON compliant (are no strings in other words). I hope that will do the trick for you.
@dillonredding no rule will be needed. Each property key that could not be used in JSON will be reported automatically by Spectral