Skip to content
Draft
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 @@ -150,6 +150,65 @@ testRule('xgen-IPA-117-request-response-bodies-must-be-well-defined', [
},
errors: [],
},
{
name: 'delete request body with schema does not crash',
document: {
paths: {
'/resource/{id}': {
delete: {
requestBody: {
content: {
'application/vnd.atlas.2024-08-05+json': {
schema: {
type: 'object',
},
},
},
},
responses: {
204: {
content: {
'application/vnd.atlas.2024-08-05+json': {},
},
},
},
},
},
},
},
errors: [],
},
{
name: 'delete request body without schema is still validated',
document: {
paths: {
'/resource/{id}': {
delete: {
requestBody: {
content: {
'application/vnd.atlas.2024-08-05+json': {},
},
},
responses: {
204: {
content: {
'application/vnd.atlas.2024-08-05+json': {},
},
},
},
},
},
},
},
errors: [
{
code: 'xgen-IPA-117-request-response-bodies-must-be-well-defined',
message: 'Request and response bodies must have a schema.',
path: ['paths', '/resource/{id}', 'delete', 'requestBody', 'content', 'application/vnd.atlas.2024-08-05+json'],
severity: DiagnosticSeverity.Error,
},
],
},
{
name: 'invalid requests and responses',
document: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export default (input, opts, { path, documentInventory, rule }) => {
// Custom POST method 2xx responses
if (
httpResponseCode === '202' ||
(httpMethod === 'delete' && httpResponseCode.startsWith('2')) ||
(httpMethod === 'delete' && httpResponseCode?.startsWith('2')) ||
(operationIsCustomMethod && httpMethod === 'post' && httpResponseCode?.startsWith('2'))
) {
return;
Expand Down
Loading