Spun out of #1188 (typed-error follow-up is in #1199). Two rules the OpenAPI / JSON Schema specs state as MUST aren't enforced by Validate() today:
1. Duplicate entries in a schema's required array. JSON Schema 2020-12 §6.5.3 (OpenAPI 3.1) and draft-04 (OpenAPI 3.0) both say the elements of required MUST be unique. Schema.validate doesn't check it, so this passes:
type: object
required: [id, id]
properties: { id: { type: string } }
2. Duplicate tag names in the document-root tags list. The OpenAPI Object spec says "Each tag name in the list MUST be unique." Tags.Validate validates each tag but never checks name uniqueness across the list, so this passes:
tags:
- name: pet
- name: pet
Both are real spec MUSTs, but enforcing them is a behavior change: docs that pass Validate() today would start failing. That's why I kept them out of #1188/#1199 (which only add scope and don't change what validates) and split them here.
@fenollp, are you up for making these hard Validate() errors, or would you rather not break existing docs over them? If you're good with it, I'll send a PR using the existing cluster pattern, something like DuplicateRequiredFieldError{Field} and DuplicateTagError{Name} (cf. DuplicateParameterError / DuplicateOperationIDError).
Spun out of #1188 (typed-error follow-up is in #1199). Two rules the OpenAPI / JSON Schema specs state as MUST aren't enforced by
Validate()today:1. Duplicate entries in a schema's
requiredarray. JSON Schema 2020-12 §6.5.3 (OpenAPI 3.1) and draft-04 (OpenAPI 3.0) both say the elements ofrequiredMUST be unique.Schema.validatedoesn't check it, so this passes:2. Duplicate tag names in the document-root
tagslist. The OpenAPI Object spec says "Each tag name in the list MUST be unique."Tags.Validatevalidates each tag but never checks name uniqueness across the list, so this passes:Both are real spec MUSTs, but enforcing them is a behavior change: docs that pass
Validate()today would start failing. That's why I kept them out of #1188/#1199 (which only add scope and don't change what validates) and split them here.@fenollp, are you up for making these hard
Validate()errors, or would you rather not break existing docs over them? If you're good with it, I'll send a PR using the existing cluster pattern, something likeDuplicateRequiredFieldError{Field}andDuplicateTagError{Name}(cf.DuplicateParameterError/DuplicateOperationIDError).