-
Hello! Is it possible to specify a default object property for object, using openapi: 3.0.3
info:
title: 'Example'
version: 0.1.0
servers:
- url: 'http://example.com'
paths:
'/foo':
delete:
responses:
'200':
description: OK
components:
schemas:
Foo:
type: object
properties:
text:
type: string
number:
type: number
Bar:
type: object
properties:
foo:
allOf:
- $ref: '#/components/schemas/Foo'
default: "Is it possible to specify a default Foo object here?" |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Yes, it is possible. OpenAPI 3.0 uses JSON Schema (draft 5) spec to define schemas. The
OpenAPI 3.0 clarifies semantics of the keyword in section 4.7.25.1 of the spec:
It means you may use Your example may be modified as: openapi: 3.0.3
info:
title: Example
version: 0.1.0
servers:
- url: http://example.com
paths:
/foo:
delete:
responses:
'200':
description: OK
components:
schemas:
Foo:
type: object
properties:
text:
type: string
number:
type: number
Bar:
type: object
properties:
foo:
allOf:
- $ref: '#/components/schemas/Foo'
default:
text: abc
number: 123 |
Beta Was this translation helpful? Give feedback.
-
This was answered and accepted, closing. |
Beta Was this translation helpful? Give feedback.
Yes, it is possible.
OpenAPI 3.0 uses JSON Schema (draft 5) spec to define schemas.
The
default
keyword is defined in JSON Schema Validation spec, section 6.2:OpenAPI 3.0 clarifies semantics of the keyword in section 4.7.25.1 of the spec: