Object Without Required Property (v3)
- Query id: d172a060-8569-4412-8045-3560ebd477e8
- Query name: Object Without Required Property (v3)
- Platform: OpenAPI
- Severity: Info
- Category: Structure and Semantics
- URL: Github
Description¶
OpenAPI Object should contain all of its required fields
Documentation
Code samples¶
Code samples with security vulnerabilities¶
Postitive test num. 1 - json file
{
"openapi": "3.0.0",
"info": {
"version": "1.0.0",
"contact": {
"name": "contact",
"url": "/",
"email": "user@gmail.com"
}
},
"paths": {}
}
Postitive test num. 2 - yaml file
openapi: 3.0.0
info:
title: Simple API Overview
contact:
name: contact
url: "/"
email: user@gmail.com
paths: {}
Postitive test num. 3 - json file
{
"openapi": "3.0.0",
"info": {
"title": "Simple API overview",
"version": "1.0.0"
},
"paths": {
"/": {
"get": {
"operationId": "listVersions",
"summary": "List versions",
"servers": [
{
"description": "server URL"
}
],
"security": [
{
"OAuth2": [
"write",
"read"
]
}
]
}
}
}
}
Postitive test num. 4 - yaml file
Postitive test num. 5 - json file
{
"openapi": "3.0.0",
"info": {
"title": "Simple API overview",
"version": "1.0.0"
},
"paths": {
"/": {
"get": {
"operationId": "listVersions",
"summary": "List versions",
"servers": [
{
"url": "http://myapi.com/",
"description": "server URL"
}
],
"security": [
{
"OAuth2": [
"write",
"read"
]
}
],
"responses": {
"200": {
"description": "200 response",
"content": {
"application/json": {
"examples": {
"foo": {
"value": {
"versions": [
{
"status": "CURRENT",
"updated": "2011-01-21T11:33:21Z",
"id": "v2.0",
"links": [
{
"href": "http://127.0.0.1:8774/v2/",
"rel": "self"
}
]
}
]
}
}
}
}
}
}
},
"requestBody": {
"description": "A JSON object containing my object information"
}
}
}
},
"components": {
"requestBodies": {
"MyObjectBody": {
"description": "A JSON object containing my object information"
},
"MyObjectBody_2": {
"description": "A JSON object containing my object information"
}
}
}
}
Postitive test num. 6 - yaml file
openapi: 3.0.0
info:
title: Simple API overview
version: 1.0.0
paths:
"/":
get:
operationId: listVersions
summary: List versions
servers:
- url: http://myapi.com/
description: server URL
security:
- OAuth2:
- write
- read
responses:
"200":
description: 200 response
content:
application/json:
examples:
foo:
value:
versions:
- status: CURRENT
updated: "2011-01-21T11:33:21Z"
id: v2.0
links:
- href: http://127.0.0.1:8774/v2/
rel: self
requestBody:
description: A JSON object containing my object information
components:
requestBodies:
MyObjectBody:
description: A JSON object containing my object information
MyObjectBody_2:
description: A JSON object containing my object information
Postitive test num. 7 - json file
{
"openapi": "3.0.0",
"info": {
"title": "Simple API overview",
"version": "1.0.0"
},
"paths": {
"/": {
"get": {
"operationId": "listVersions",
"summary": "List versions",
"servers": [
{
"url": "http://myapi.com/",
"description": "server URL"
}
],
"security": [
{
"OAuth2": [
"write",
"read"
]
}
],
"responses": {
"200": {
"content": {
"application/json": {
"examples": {
"foo": {
"value": {
"versions": [
{
"status": "CURRENT",
"updated": "2011-01-21T11:33:21Z",
"id": "v2.0",
"links": [
{
"href": "http://127.0.0.1:8774/v2/",
"rel": "self"
}
]
}
]
}
}
}
}
}
}
},
"parameters": [
{
"in": "path",
"description": "ID of pet to use",
"required": true,
"schema": {
"type": "array",
"items": {
"type": "string"
}
},
"style": "simple"
}
]
}
}
},
"components": {
"parameters": {
"IdParam": {
"name": "id",
"description": "ID of pet to use",
"required": true,
"schema": {
"type": "array",
"items": {
"type": "string"
}
},
"style": "simple"
}
}
}
}
Postitive test num. 8 - yaml file
openapi: 3.0.0
info:
title: Simple API overview
version: 1.0.0
paths:
"/":
get:
operationId: listVersions
summary: List versions
servers:
- url: http://myapi.com/
description: server URL
security:
- OAuth2:
- write
- read
responses:
"200":
content:
application/json:
examples:
foo:
value:
versions:
- status: CURRENT
updated: "2011-01-21T11:33:21Z"
id: v2.0
links:
- href: http://127.0.0.1:8774/v2/
rel: self
parameters:
- in: path
description: ID of pet to use
required: true
schema:
type: array
items:
type: string
style: simple
components:
parameters:
IdParam:
name: id
description: ID of pet to use
required: true
schema:
type: array
items:
type: string
style: simple
Code samples without security vulnerabilities¶
Negative test num. 1 - json file
{
"openapi": "3.0.0",
"info": {
"title": "Simple API Overview",
"version": "1.0.0",
"contact": {
"name": "contact",
"url": "/",
"email": "user@gmail.com"
}
},
"paths": {}
}
Negative test num. 2 - yaml file
openapi: 3.0.0
info:
title: Simple API Overview
version: 1.0.0
contact:
name: contact
url: "/"
email: user@gmail.com
paths: {}
Negative test num. 3 - json file
{
"openapi": "3.0.0",
"info": {
"title": "Simple API overview",
"version": "1.0.0"
},
"paths": {
"/": {
"get": {
"operationId": "listVersions",
"summary": "List versions",
"servers": [
{
"url": "http://myapi.com/",
"description": "server URL"
}
],
"security": [
{
"OAuth2": [
"write",
"read"
]
}
],
"responses": {
"200": {
"description": "200 response",
"content": {
"application/json": {
"examples": {
"foo": {
"value": {
"versions": [
{
"status": "CURRENT",
"updated": "2011-01-21T11:33:21Z",
"id": "v2.0",
"links": [
{
"href": "http://127.0.0.1:8774/v2/",
"rel": "self"
}
]
}
]
}
}
}
}
}
}
}
}
}
}
}
Negative test num. 4 - yaml file
openapi: 3.0.0
info:
title: Simple API overview
version: 1.0.0
paths:
"/":
get:
operationId: listVersions
summary: List versions
servers:
- url: http://myapi.com/
description: server URL
security:
- OAuth2:
- write
- read
responses:
"200":
description: 200 response
content:
application/json:
examples:
foo:
value:
versions:
- status: CURRENT
updated: "2011-01-21T11:33:21Z"
id: v2.0
links:
- href: http://127.0.0.1:8774/v2/
rel: self
Negative test num. 5 - json file
{
"openapi": "3.0.0",
"info": {
"title": "Simple API overview",
"version": "1.0.0"
},
"paths": {
"/": {
"get": {
"operationId": "listVersions",
"summary": "List versions",
"servers": [
{
"url": "http://myapi.com/",
"description": "server URL"
}
],
"security": [
{
"OAuth2": [
"write",
"read"
]
}
],
"responses": {
"200": {
"description": "200 response",
"content": {
"application/json": {
"examples": {
"foo": {
"value": {
"versions": [
{
"status": "CURRENT",
"updated": "2011-01-21T11:33:21Z",
"id": "v2.0",
"links": [
{
"href": "http://127.0.0.1:8774/v2/",
"rel": "self"
}
]
}
]
}
}
}
}
}
}
},
"requestBody": {
"description": "A JSON object containing my object information",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/MyObject"
}
}
}
}
}
}
},
"components": {
"requestBodies": {
"MyObjectBody": {
"description": "A JSON object containing my object information",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/MyObject"
}
}
}
},
"MyObjectBody_2": {
"description": "A JSON object containing my object information",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/MyObject"
}
}
}
}
}
}
}
Negative test num. 6 - yaml file
openapi: 3.0.0
info:
title: Simple API overview
version: 1.0.0
paths:
"/":
get:
operationId: listVersions
summary: List versions
servers:
- url: http://myapi.com/
description: server URL
security:
- OAuth2:
- write
- read
responses:
"200":
description: 200 response
content:
application/json:
examples:
foo:
value:
versions:
- status: CURRENT
updated: "2011-01-21T11:33:21Z"
id: v2.0
links:
- href: http://127.0.0.1:8774/v2/
rel: self
requestBody:
description: A JSON object containing my object information
content:
application/json:
schema:
"$ref": "#/components/schemas/MyObject"
components:
requestBodies:
MyObjectBody:
description: A JSON object containing my object information
content:
application/json:
schema:
"$ref": "#/components/schemas/MyObject"
MyObjectBody_2:
description: A JSON object containing my object information
content:
application/json:
schema:
"$ref": "#/components/schemas/MyObject"
Negative test num. 7 - json file
{
"openapi": "3.0.0",
"info": {
"title": "Simple API overview",
"version": "1.0.0"
},
"paths": {
"/": {
"get": {
"operationId": "listVersions",
"summary": "List versions",
"servers": [
{
"url": "http://myapi.com/",
"description": "server URL"
}
],
"security": [
{
"OAuth2": [
"write",
"read"
]
}
],
"responses": {
"200": {
"description": "200 response",
"content": {
"application/json": {
"examples": {
"foo": {
"value": {
"versions": [
{
"status": "CURRENT",
"updated": "2011-01-21T11:33:21Z",
"id": "v2.0",
"links": [
{
"href": "http://127.0.0.1:8774/v2/",
"rel": "self"
}
]
}
]
}
}
}
}
}
}
},
"parameters": [
{
"name": "id",
"in": "path",
"description": "ID of pet to use",
"required": true,
"schema": {
"type": "array",
"items": {
"type": "string"
}
},
"style": "simple"
}
]
}
}
},
"components": {
"parameters": {
"IdParam": {
"name": "id",
"in": "path",
"description": "ID of pet to use",
"required": true,
"schema": {
"type": "array",
"items": {
"type": "string"
}
},
"style": "simple"
}
}
}
}
Negative test num. 8 - yaml file
openapi: 3.0.0
info:
title: Simple API overview
version: 1.0.0
paths:
"/":
get:
operationId: listVersions
summary: List versions
servers:
- url: http://myapi.com/
description: server URL
security:
- OAuth2:
- write
- read
responses:
"200":
description: 200 response
content:
application/json:
examples:
foo:
value:
versions:
- status: CURRENT
updated: "2011-01-21T11:33:21Z"
id: v2.0
links:
- href: http://127.0.0.1:8774/v2/
rel: self
parameters:
- name: id
in: path
description: ID of pet to use
required: true
schema:
type: array
items:
type: string
style: simple
components:
parameters:
IdParam:
name: id
in: path
description: ID of pet to use
required: true
schema:
type: array
items:
type: string
style: simple