Skip to content

Default value not applied when it's defined through $ref #473

@acelot

Description

@acelot

Schema (YML):

definitions:
  limit:
    type: integer
    minimum: 1
    maximum: 100
    default: 10

test:
  type: object
  properties:
    query:
      type: string
    limit:
      $ref: "#/definitions/limit"
    offset:
      type: integer
      default: 0

JSON:

{
  "query": "test"
}

Validation:

$validator->validate($request, $schema, Constraint::CHECK_MODE_APPLY_DEFAULTS);

Request after validation:

{
  "query": "test",
  "offset": 0
}

It seems validator doesn't apply default value in $refs.
Version: 5.2.6
PHP: 7.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions