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 @@ -152,7 +152,7 @@ testRule('xgen-IPA-104-get-method-returns-response-suffixed-object', [
errors: [
{
code: 'xgen-IPA-104-get-method-returns-response-suffixed-object',
message: 'The response body schema must reference a schema with a Response suffix.',
message: 'The schema must reference a schema with a Response suffix.',
path: [
'paths',
'/resource/{id}',
Expand All @@ -166,7 +166,7 @@ testRule('xgen-IPA-104-get-method-returns-response-suffixed-object', [
},
{
code: 'xgen-IPA-104-get-method-returns-response-suffixed-object',
message: 'The response body schema must reference a schema with a Response suffix.',
message: 'The schema must reference a schema with a Response suffix.',
path: [
'paths',
'/resource/{id}',
Expand All @@ -180,7 +180,7 @@ testRule('xgen-IPA-104-get-method-returns-response-suffixed-object', [
},
{
code: 'xgen-IPA-104-get-method-returns-response-suffixed-object',
message: 'The response body schema must reference a schema with a Response suffix.',
message: 'The schema must reference a schema with a Response suffix.',
path: [
'paths',
'/resource/{id}',
Expand All @@ -194,7 +194,7 @@ testRule('xgen-IPA-104-get-method-returns-response-suffixed-object', [
},
{
code: 'xgen-IPA-104-get-method-returns-response-suffixed-object',
message: 'The response body schema must reference a schema with a Response suffix.',
message: 'The schema must reference a schema with a Response suffix.',
path: [
'paths',
'/resource/{id}/singleton',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,31 +154,31 @@ testRule('xgen-IPA-106-create-method-request-body-is-request-suffixed-object', [
errors: [
{
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. ',
message: 'The schema must reference a schema with a Request suffix.',
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. ',
message: 'The schema must reference a schema with a Request suffix.',
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. ',
message: 'The schema must reference a schema with a Request suffix.',
path: ['paths', '/resourceTwo', '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. ',
message: 'The schema must reference a schema with a Request suffix.',
path: ['paths', '/resourceTwo', '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 is defined inline and must reference a predefined schema. ',
message: 'The schema is defined inline and must reference a predefined schema.',
path: ['paths', '/resourceThree', 'post', 'requestBody', 'content', 'application/vnd.atlas.2023-01-01+json'],
severity: DiagnosticSeverity.Warning,
},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,300 @@
import testRule from './__helpers__/testRule';
import { DiagnosticSeverity } from '@stoplight/types';

const componentSchemas = {
schemas: {
SchemaUpdateRequest: {
type: 'object',
},
Schema: {
type: 'object',
},
},
};

testRule('xgen-IPA-107-update-method-request-body-is-update-request-suffixed-object', [
{
name: 'valid schema names names',
document: {
paths: {
'/resource/{id}': {
patch: {
requestBody: {
content: {
'application/vnd.atlas.2024-01-01+json': {
schema: {
$ref: '#/components/schemas/SchemaUpdateRequest',
},
},
'application/vnd.atlas.2025-01-01+json': {
schema: {
type: 'array',
items: {
$ref: '#/components/schemas/SchemaUpdateRequest',
},
},
},
},
},
},
put: {
requestBody: {
content: {
'application/vnd.atlas.2024-01-01+json': {
schema: {
$ref: '#/components/schemas/SchemaUpdateRequest',
},
},
'application/vnd.atlas.2025-01-01+json': {
schema: {
type: 'array',
items: {
$ref: '#/components/schemas/SchemaUpdateRequest',
},
},
},
},
},
},
},
'/resourceTwo/{id}': {
patch: {
requestBody: {
content: {
'application/vnd.atlas.2024-08-05+json': {
type: 'string',
},
},
},
},
},
'/resource/{id}/singleton': {
patch: {
requestBody: {
content: {
'application/vnd.atlas.2024-08-05+json': {
schema: {
$ref: '#/components/schemas/SchemaUpdateRequest',
},
},
},
},
},
},
},
components: componentSchemas,
},
errors: [],
},
{
name: 'invalid resources',
document: {
paths: {
'/resource/{id}': {
patch: {
requestBody: {
content: {
'application/vnd.atlas.2024-01-01+json': {
schema: {
$ref: '#/components/schemas/Schema',
},
},
'application/vnd.atlas.2025-01-01+json': {
schema: {
type: 'array',
items: {
$ref: '#/components/schemas/Schema',
},
},
},
},
},
},
put: {
requestBody: {
content: {
'application/vnd.atlas.2024-01-01+json': {
schema: {
$ref: '#/components/schemas/Schema',
},
},
'application/vnd.atlas.2025-01-01+json': {
schema: {
type: 'array',
items: {
$ref: '#/components/schemas/Schema',
},
},
},
},
},
},
},
'/resource/{id}/singleton': {
patch: {
requestBody: {
content: {
'application/vnd.atlas.2024-08-05+json': {
schema: {
$ref: '#/components/schemas/Schema',
},
},
},
},
},
put: {
requestBody: {
content: {
'application/vnd.atlas.2024-08-05+json': {
schema: {
$ref: '#/components/schemas/Schema',
},
},
},
},
},
},
},
components: componentSchemas,
},
errors: [
{
code: 'xgen-IPA-107-update-method-request-body-is-update-request-suffixed-object',
message: 'The schema must reference a schema with a UpdateRequest suffix.',
path: ['paths', '/resource/{id}', 'patch', 'requestBody', 'content', 'application/vnd.atlas.2024-01-01+json'],
severity: DiagnosticSeverity.Warning,
},
{
code: 'xgen-IPA-107-update-method-request-body-is-update-request-suffixed-object',
message: 'The schema must reference a schema with a UpdateRequest suffix.',
path: ['paths', '/resource/{id}', 'patch', 'requestBody', 'content', 'application/vnd.atlas.2025-01-01+json'],
severity: DiagnosticSeverity.Warning,
},
{
code: 'xgen-IPA-107-update-method-request-body-is-update-request-suffixed-object',
message: 'The schema must reference a schema with a UpdateRequest suffix.',
path: ['paths', '/resource/{id}', 'put', 'requestBody', 'content', 'application/vnd.atlas.2024-01-01+json'],
severity: DiagnosticSeverity.Warning,
},
{
code: 'xgen-IPA-107-update-method-request-body-is-update-request-suffixed-object',
message: 'The schema must reference a schema with a UpdateRequest suffix.',
path: ['paths', '/resource/{id}', 'put', 'requestBody', 'content', 'application/vnd.atlas.2025-01-01+json'],
severity: DiagnosticSeverity.Warning,
},
{
code: 'xgen-IPA-107-update-method-request-body-is-update-request-suffixed-object',
message: 'The schema must reference a schema with a UpdateRequest suffix.',
path: [
'paths',
'/resource/{id}/singleton',
'patch',
'requestBody',
'content',
'application/vnd.atlas.2024-08-05+json',
],
severity: DiagnosticSeverity.Warning,
},
{
code: 'xgen-IPA-107-update-method-request-body-is-update-request-suffixed-object',
message: 'The schema must reference a schema with a UpdateRequest suffix.',
path: [
'paths',
'/resource/{id}/singleton',
'put',
'requestBody',
'content',
'application/vnd.atlas.2024-08-05+json',
],
severity: DiagnosticSeverity.Warning,
},
],
},
{
name: 'invalid resources with exceptions',
document: {
paths: {
'/resource/{id}': {
patch: {
requestBody: {
'application/vnd.atlas.2024-01-01+json': {
'x-xgen-IPA-exception': {
'xgen-IPA-107-update-method-request-body-is-update-request-suffixed-object': 'reason',
},
schema: {
$ref: '#/components/schemas/Schema',
},
},
'application/vnd.atlas.2025-01-01+json': {
'x-xgen-IPA-exception': {
'xgen-IPA-107-update-method-request-body-is-update-request-suffixed-object': 'reason',
},
schema: {
type: 'array',
items: {
$ref: '#/components/schemas/Schema',
},
},
},
},
},
put: {
requestBody: {
'application/vnd.atlas.2024-01-01+json': {
'x-xgen-IPA-exception': {
'xgen-IPA-107-update-method-request-body-is-update-request-suffixed-object': 'reason',
},
schema: {
$ref: '#/components/schemas/Schema',
},
},
'application/vnd.atlas.2025-01-01+json': {
'x-xgen-IPA-exception': {
'xgen-IPA-107-update-method-request-body-is-update-request-suffixed-object': 'reason',
},
schema: {
type: 'array',
items: {
$ref: '#/components/schemas/Schema',
},
},
},
},
},
},
'/resource/{id}/singleton': {
patch: {
requestBody: {
content: {
'application/vnd.atlas.2024-08-05+json': {
'x-xgen-IPA-exception': {
'xgen-IPA-107-update-method-request-body-is-update-request-suffixed-object': 'reason',
},
schema: {
$ref: '#/components/schemas/Schema',
},
},
},
},
},
put: {
requestBody: {
content: {
'application/vnd.atlas.2024-08-05+json': {
'x-xgen-IPA-exception': {
'xgen-IPA-107-update-method-request-body-is-update-request-suffixed-object': 'reason',
},
schema: {
$ref: '#/components/schemas/Schema',
},
},
},
},
},
},
},
components: componentSchemas,
},
errors: [],
},
]);
Loading
Loading