Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ testRule('xgen-IPA-106-create-method-request-body-is-request-suffixed-object', [
$ref: '#/components/schemas/SchemaRequest',
},
},
'application/vnd.atlas.2025-01-01+json': {
schema: {
type: 'array',
items: {
$ref: '#/components/schemas/SchemaRequest',
},
},
},
},
},
},
Expand Down Expand Up @@ -89,6 +97,14 @@ testRule('xgen-IPA-106-create-method-request-body-is-request-suffixed-object', [
$ref: '#/components/schemas/Schema',
},
},
'application/vnd.atlas.2024-01-01+json': {
schema: {
type: 'array',
items: {
$ref: '#/components/schemas/Schema',
},
},
},
},
},
},
Expand Down Expand Up @@ -133,6 +149,12 @@ testRule('xgen-IPA-106-create-method-request-body-is-request-suffixed-object', [
path: ['paths', '/resource', 'post', 'requestBody', 'content', 'application/vnd.atlas.2023-01-01+json'],
severity: DiagnosticSeverity.Warning,
},
{
code: 'xgen-IPA-106-create-method-request-body-is-request-suffixed-object',
message: 'The response body schema must reference a schema with a Request suffix. http://go/ipa/106',
path: ['paths', '/resource', 'post', 'requestBody', 'content', 'application/vnd.atlas.2024-01-01+json'],
severity: DiagnosticSeverity.Warning,
},
{
code: 'xgen-IPA-106-create-method-request-body-is-request-suffixed-object',
message: 'The response body schema must reference a schema with a Request suffix. http://go/ipa/106',
Expand Down Expand Up @@ -170,6 +192,17 @@ testRule('xgen-IPA-106-create-method-request-body-is-request-suffixed-object', [
'xgen-IPA-106-create-method-request-body-is-request-suffixed-object': 'reason',
},
},
'application/vnd.atlas.2024-01-01+json': {
schema: {
type: 'array',
items: {
$ref: '#/components/schemas/Schema',
},
},
'x-xgen-IPA-exception': {
'xgen-IPA-106-create-method-request-body-is-request-suffixed-object': 'reason',
},
},
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,24 @@ export default (input, _, { path, documentInventory }) => {

if (contentPerMediaType.schema) {
const schema = contentPerMediaType.schema;
if (!schema.$ref) {
return collectAndReturnViolation(path, RULE_NAME, ERROR_MESSAGE_SCHEMA_REF);
if (schema.type === 'array' && schema.items) {
let schemaItems = schema.items;
if (!schemaItems.$ref) {
return collectAndReturnViolation(path, RULE_NAME, ERROR_MESSAGE_SCHEMA_REF);
}
if (!schemaItems.$ref.endsWith('Request')) {
return collectAndReturnViolation(path, RULE_NAME, ERROR_MESSAGE_SCHEMA_NAME);
}
} else {
if (!schema.$ref) {
return collectAndReturnViolation(path, RULE_NAME, ERROR_MESSAGE_SCHEMA_REF);
}

if (!schema.$ref.endsWith('Request')) {
return collectAndReturnViolation(path, RULE_NAME, ERROR_MESSAGE_SCHEMA_NAME);
}
}

if (!schema.$ref.endsWith('Request')) {
return collectAndReturnViolation(path, RULE_NAME, ERROR_MESSAGE_SCHEMA_NAME);
}
collectAdoption(path, RULE_NAME);
}

collectAdoption(path, RULE_NAME);
};
Loading