Skip to content

Commit b48e430

Browse files
error message fix
1 parent f72a013 commit b48e430

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

tools/spectral/ipa/__tests__/createMethodRequestBodyIsRequestSuffixedObject.test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,25 +129,25 @@ testRule('xgen-IPA-106-create-method-request-body-is-request-suffixed-object', [
129129
errors: [
130130
{
131131
code: 'xgen-IPA-106-create-method-request-body-is-request-suffixed-object',
132-
message: 'Response body for the Create method should refer to Request suffixed schema. http://go/ipa/106',
132+
message: 'The response body schema must reference a schema with a Request suffix. http://go/ipa/106',
133133
path: ['paths', '/resource', 'post', 'requestBody', 'content', 'application/vnd.atlas.2023-01-01+json'],
134134
severity: DiagnosticSeverity.Warning,
135135
},
136136
{
137137
code: 'xgen-IPA-106-create-method-request-body-is-request-suffixed-object',
138-
message: 'Response body for the Create method should refer to Request suffixed schema. http://go/ipa/106',
138+
message: 'The response body schema must reference a schema with a Request suffix. http://go/ipa/106',
139139
path: ['paths', '/resource2', 'post', 'requestBody', 'content', 'application/vnd.atlas.2023-01-01+json'],
140140
severity: DiagnosticSeverity.Warning,
141141
},
142142
{
143143
code: 'xgen-IPA-106-create-method-request-body-is-request-suffixed-object',
144-
message: 'Response body for the Create method should refer to Request suffixed schema. http://go/ipa/106',
144+
message: 'The response body schema must reference a schema with a Request suffix. http://go/ipa/106',
145145
path: ['paths', '/resource2', 'post', 'requestBody', 'content', 'application/vnd.atlas.2024-01-01+json'],
146146
severity: DiagnosticSeverity.Warning,
147147
},
148148
{
149149
code: 'xgen-IPA-106-create-method-request-body-is-request-suffixed-object',
150-
message: 'Response body for the Create method should refer to Request suffixed schema. http://go/ipa/106',
150+
message: 'The response body schema is defined inline and must reference a predefined schema. http://go/ipa/106',
151151
path: ['paths', '/resource3', 'post', 'requestBody', 'content', 'application/vnd.atlas.2023-01-01+json'],
152152
severity: DiagnosticSeverity.Warning,
153153
},

tools/spectral/ipa/rulesets/functions/createMethodRequestBodyIsRequestSuffixedObject.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ import { isCustomMethod } from './utils/resourceEvaluation.js';
44
import { resolveObject } from './utils/componentUtils.js';
55

66
const RULE_NAME = 'xgen-IPA-106-create-method-request-body-is-request-suffixed-object';
7-
const ERROR_MESSAGE = 'Response body for the Create method should refer to Request suffixed schema.';
7+
const ERROR_MESSAGE_SCHEMA_NAME = 'The response body schema must reference a schema with a Request suffix.';
8+
const ERROR_MESSAGE_SCHEMA_REF = 'The response body schema is defined inline and must reference a predefined schema.';
89

910
export default (input, _, { path, documentInventory }) => {
1011
const oas = documentInventory.unresolved;
@@ -24,11 +25,11 @@ export default (input, _, { path, documentInventory }) => {
2425
if (contentPerMediaType.schema) {
2526
const schema = contentPerMediaType.schema;
2627
if(!schema.$ref) {
27-
return collectAndReturnViolation(path, RULE_NAME, ERROR_MESSAGE);
28+
return collectAndReturnViolation(path, RULE_NAME, ERROR_MESSAGE_SCHEMA_REF);
2829
}
2930

3031
if (!schema.$ref.endsWith('Request')) {
31-
return collectAndReturnViolation(path, RULE_NAME, ERROR_MESSAGE);
32+
return collectAndReturnViolation(path, RULE_NAME, ERROR_MESSAGE_SCHEMA_NAME);
3233
}
3334
}
3435

0 commit comments

Comments
 (0)