Skip to content

Should required properties in a component be allowed if not included in properties? #2918

Closed Answered by hkosova
mull asked this question in Q&A
Discussion options

You must be logged in to vote

Your example is valid and is equivalent to this (YAML version for readability):

Object:
  required: [id, title, created_at]
  type: object
  properties:
    id:
      type: integer
    title:
      description: Title for the new object.
      type: string
    created_at: {}   # The value can be of any type

Extra properties not explicitly defined under properties are allowed unless the schema has additionalProperties: false / unevaluatedProperties: false.

You can use a linter to enforce that the properties listed in the required list are explicitly defined in properties.

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
2 replies
@mull
Comment options

@jeremyfiel
Comment options

Answer selected by mull
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants