The current RC1 version explains the different default types in section Shortcuts and Syntactic Sugar. In RC2 we should make sure that these are described a bit more clearly w/o using examples only.
There following rules need to be applied to determine the default type:
If, and only if, a type declaration contains a properties node; the default type is object. For example (based on this rule):
types:
Person:
type: object
properties:
can also be written
types:
Person:
# default type is `object`, no need to explicitly define it
properties:
If, and only if, a type declaration does not contain either a properties node or no explicit type/schema node; the default type is always string. For example (based on this rule):
types:
Person:
properties:
name: # no type or schema necessary since the default type is `string`
The default type any is applied to any body node regardless if it is a response or request declaration that does not contain properties, types, or schema. That rule is necessary since the value of a body node has the same structure like a type declaration except that the key is always a media type. For example:
body:
application/json: # key
# default type is `any`
The last rule is important for validation purposes and needs to be defined in the specification. Of course, each rule can be overridden by explicitly define a type. For example:
The current RC1 version explains the different default types in section Shortcuts and Syntactic Sugar. In RC2 we should make sure that these are described a bit more clearly w/o using examples only.
There following rules need to be applied to determine the default type:
properties
node; the default type isobject
. For example (based on this rule):can also be written
properties
node or no explicittype
/schema
node; the default type is alwaysstring
. For example (based on this rule):any
is applied to anybody
node regardless if it is a response or request declaration that does not containproperties
,types
, orschema
. That rule is necessary since the value of abody
node has the same structure like a type declaration except that the key is always a media type. For example:The last rule is important for validation purposes and needs to be defined in the specification. Of course, each rule can be overridden by explicitly define a type. For example: