mirror of
https://github.com/LukeHagar/redocly-cli.git
synced 2025-12-06 04:21:09 +00:00
Upcase "4XX" in error message of operation-4xx-response (#841)
This commit is contained in:
@@ -6,7 +6,7 @@ The lint field is deprecated. Use styleguide instead. Read more about this chang
|
||||
validating /openapi.yaml...
|
||||
[1] openapi.yaml:11:7 at #/paths/~1pet~1findByStatus/get/responses
|
||||
|
||||
Operation must have at least one \`4xx\` response.
|
||||
Operation must have at least one \`4XX\` response.
|
||||
|
||||
9 | operationId: example
|
||||
10 | summary: summary example
|
||||
|
||||
@@ -33,7 +33,7 @@ Warning was generated by the info-license rule.
|
||||
|
||||
[3] openapi.yaml:14:7 at #/paths/~1pet~1findByStatus/get/responses
|
||||
|
||||
Operation must have at least one \`4xx\` response.
|
||||
Operation must have at least one \`4XX\` response.
|
||||
|
||||
12 | operationId: example
|
||||
13 | summary: summary example
|
||||
|
||||
@@ -5,7 +5,7 @@ exports[`E2E lint operation-2xx-response-warning 1`] = `
|
||||
validating /openapi.yaml...
|
||||
[1] openapi.yaml:11:7 at #/paths/~1ping/get/responses
|
||||
|
||||
Operation must have at least one \`2xx\` response.
|
||||
Operation must have at least one \`2XX\` response.
|
||||
|
||||
9 | operationId: gitPing
|
||||
10 | summary: example text
|
||||
|
||||
@@ -5,7 +5,7 @@ exports[`E2E lint operation-4xx-response-warning 1`] = `
|
||||
validating /openapi.yaml...
|
||||
[1] openapi.yaml:11:7 at #/paths/~1ping/get/responses
|
||||
|
||||
Operation must have at least one \`4xx\` response.
|
||||
Operation must have at least one \`4XX\` response.
|
||||
|
||||
9 | operationId: gitPing
|
||||
10 | summary: example text
|
||||
|
||||
@@ -112,7 +112,7 @@ Error was generated by the path-parameters-defined rule.
|
||||
|
||||
[9] openapi.yaml:16:7 at #/paths/~1ping~1{id}~1{test}/get/responses
|
||||
|
||||
Operation must have at least one \`4xx\` response.
|
||||
Operation must have at least one \`4XX\` response.
|
||||
|
||||
14 | schema:
|
||||
15 | type: string
|
||||
|
||||
@@ -34,7 +34,7 @@ describe('Oas3 operation-2xx-response', () => {
|
||||
"source": "foobar.yaml",
|
||||
},
|
||||
],
|
||||
"message": "Operation must have at least one \`2xx\` response.",
|
||||
"message": "Operation must have at least one \`2XX\` response.",
|
||||
"ruleId": "operation-2xx-response",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
|
||||
@@ -34,7 +34,7 @@ describe('Oas3 operation-4xx-response', () => {
|
||||
"source": "foobar.yaml",
|
||||
},
|
||||
],
|
||||
"message": "Operation must have at least one \`4xx\` response.",
|
||||
"message": "Operation must have at least one \`4XX\` response.",
|
||||
"ruleId": "operation-4xx-response",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
@@ -43,7 +43,7 @@ describe('Oas3 operation-4xx-response', () => {
|
||||
`);
|
||||
});
|
||||
|
||||
it('should not report for present 4xx response', async () => {
|
||||
it('should not report for present 400 response', async () => {
|
||||
const document = parseYamlToDocument(
|
||||
outdent`
|
||||
openapi: 3.0.0
|
||||
@@ -66,6 +66,29 @@ describe('Oas3 operation-4xx-response', () => {
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`);
|
||||
});
|
||||
|
||||
it('should not report for present 4XX response', async () => {
|
||||
const document = parseYamlToDocument(
|
||||
outdent`
|
||||
openapi: 3.0.0
|
||||
paths:
|
||||
'/test/':
|
||||
put:
|
||||
responses:
|
||||
4XX:
|
||||
description: error response
|
||||
`,
|
||||
'foobar.yaml'
|
||||
);
|
||||
|
||||
const results = await lintDocument({
|
||||
externalRefResolver: new BaseResolver(),
|
||||
document,
|
||||
config: await makeConfig({ 'operation-4xx-response': 'error' }),
|
||||
});
|
||||
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`);
|
||||
});
|
||||
|
||||
it('should report if default is present but missing 4xx response', async () => {
|
||||
const document = parseYamlToDocument(
|
||||
outdent`
|
||||
@@ -96,7 +119,7 @@ describe('Oas3 operation-4xx-response', () => {
|
||||
"source": "foobar.yaml",
|
||||
},
|
||||
],
|
||||
"message": "Operation must have at least one \`4xx\` response.",
|
||||
"message": "Operation must have at least one \`4XX\` response.",
|
||||
"ruleId": "operation-4xx-response",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
|
||||
@@ -7,7 +7,7 @@ export const Operation2xxResponse: Oas3Rule | Oas2Rule = () => {
|
||||
const codes = Object.keys(responses);
|
||||
if (!codes.some((code) => code === 'default' || /2[Xx0-9]{2}/.test(code))) {
|
||||
report({
|
||||
message: 'Operation must have at least one `2xx` response.',
|
||||
message: 'Operation must have at least one `2XX` response.',
|
||||
location: { reportOnKey: true },
|
||||
});
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ export const Operation4xxResponse: Oas3Rule | Oas2Rule = () => {
|
||||
|
||||
if (!codes.some((code) => /4[Xx0-9]{2}/.test(code))) {
|
||||
report({
|
||||
message: 'Operation must have at least one `4xx` response.',
|
||||
message: 'Operation must have at least one `4XX` response.',
|
||||
location: { reportOnKey: true },
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user