mirror of
https://github.com/LukeHagar/redocly-cli.git
synced 2025-12-06 04:21:09 +00:00
fix: add separate node type for patternProperties (#1644)
* fix: add PatternProperties type to target patternProperties separately from properties * add changeset * remove redundancy * commit redocly.yaml and update .gitignore to only target root redocly.yaml * Update .changeset/sour-pandas-wave.md Co-authored-by: JLekawa <164185257+JLekawa@users.noreply.github.com> --------- Co-authored-by: JLekawa <164185257+JLekawa@users.noreply.github.com>
This commit is contained in:
6
.changeset/sour-pandas-wave.md
Normal file
6
.changeset/sour-pandas-wave.md
Normal file
@@ -0,0 +1,6 @@
|
||||
---
|
||||
"@redocly/openapi-core": patch
|
||||
"@redocly/cli": patch
|
||||
---
|
||||
|
||||
Fixed an issue where `patternProperties` incorrectly caused linting errors due to a missing `PatternProperties` node.
|
||||
8
.gitignore
vendored
8
.gitignore
vendored
@@ -13,7 +13,7 @@ output/
|
||||
*.tgz
|
||||
redoc-static.html
|
||||
packages/cli/README.md
|
||||
redocly.yaml
|
||||
.redocly.yaml
|
||||
redocly.yml
|
||||
.redocly.yml
|
||||
/redocly.yaml
|
||||
/.redocly.yaml
|
||||
/redocly.yml
|
||||
/.redocly.yml
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
12
__tests__/lint/assertions-patternProperties/openapi.yaml
Normal file
12
__tests__/lint/assertions-patternProperties/openapi.yaml
Normal file
@@ -0,0 +1,12 @@
|
||||
openapi: 3.1.0
|
||||
info: {}
|
||||
paths:
|
||||
/test:
|
||||
get:
|
||||
responses:
|
||||
default:
|
||||
description: test
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: schema.json
|
||||
10
__tests__/lint/assertions-patternProperties/redocly.yaml
Normal file
10
__tests__/lint/assertions-patternProperties/redocly.yaml
Normal file
@@ -0,0 +1,10 @@
|
||||
apis:
|
||||
main:
|
||||
root: ./openapi.yaml
|
||||
|
||||
rules:
|
||||
rule/response-in-snake_case:
|
||||
subject:
|
||||
type: SchemaProperties
|
||||
assertions:
|
||||
casing: snake_case
|
||||
16
__tests__/lint/assertions-patternProperties/schema.json
Normal file
16
__tests__/lint/assertions-patternProperties/schema.json
Normal file
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"incorrectlyNamedProperty": {
|
||||
"type": "string"
|
||||
},
|
||||
"a_property_in_snake_case": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"patternProperties": {
|
||||
"^.+$": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
26
__tests__/lint/assertions-patternProperties/snapshot.js
Normal file
26
__tests__/lint/assertions-patternProperties/snapshot.js
Normal file
@@ -0,0 +1,26 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`E2E lint assertions-patternProperties 1`] = `
|
||||
|
||||
validating /openapi.yaml...
|
||||
[1] schema.json:4:5 at #/properties/incorrectlyNamedProperty
|
||||
|
||||
rule/response-in-snake_case failed because the SchemaProperties didn't meet the assertions: "incorrectlyNamedProperty" should use snake_case
|
||||
|
||||
2 | "type": "object",
|
||||
3 | "properties": {
|
||||
4 | "incorrectlyNamedProperty": {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
5 | "type": "string"
|
||||
6 | },
|
||||
|
||||
Error was generated by the rule/response-in-snake_case rule.
|
||||
|
||||
|
||||
/openapi.yaml: validated in <test>ms
|
||||
|
||||
❌ Validation failed with 1 error.
|
||||
run \`redocly lint --generate-ignore-file\` to add all problems to the ignore file.
|
||||
|
||||
|
||||
`;
|
||||
@@ -139,7 +139,7 @@ const Schema: NodeType = {
|
||||
contains: 'Schema',
|
||||
minContains: { type: 'integer', minimum: 0 },
|
||||
maxContains: { type: 'integer', minimum: 0 },
|
||||
patternProperties: 'SchemaProperties',
|
||||
patternProperties: 'PatternProperties',
|
||||
propertyNames: 'Schema',
|
||||
unevaluatedItems: (value: unknown) => {
|
||||
if (typeof value === 'boolean') {
|
||||
@@ -278,6 +278,7 @@ export const Oas3_1Types: Record<Oas3_1NodeType, NodeType> = {
|
||||
Root,
|
||||
Schema,
|
||||
SchemaProperties,
|
||||
PatternProperties: SchemaProperties,
|
||||
License,
|
||||
Components,
|
||||
NamedPathItems: mapOf('PathItem'),
|
||||
|
||||
@@ -234,6 +234,7 @@ const oas3_1NodeTypesList = [
|
||||
'Root',
|
||||
'Schema',
|
||||
'SchemaProperties',
|
||||
'PatternProperties',
|
||||
'Info',
|
||||
'License',
|
||||
'Components',
|
||||
|
||||
Reference in New Issue
Block a user