From f34083a6eb30cf347c88cb71b0c044f4334884cb Mon Sep 17 00:00:00 2001 From: Karen Etheridge Date: Sun, 31 Aug 2025 16:07:00 -0700 Subject: [PATCH] "example" and "examples" cannot appear together This affects the places where examples are used: parameter, header, and media-type objects for #4598, ported from #4912. --- src/schemas/validation/schema.yaml | 4 ++++ tests/schema/fail/example-examples.yaml | 20 ++++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 tests/schema/fail/example-examples.yaml diff --git a/src/schemas/validation/schema.yaml b/src/schemas/validation/schema.yaml index bfa2fcf3ea..b728cbfb98 100644 --- a/src/schemas/validation/schema.yaml +++ b/src/schemas/validation/schema.yaml @@ -951,6 +951,10 @@ $defs: type: object additionalProperties: $ref: '#/$defs/example-or-reference' + not: + required: + - example + - examples map-of-strings: type: object diff --git a/tests/schema/fail/example-examples.yaml b/tests/schema/fail/example-examples.yaml new file mode 100644 index 0000000000..97adcadba6 --- /dev/null +++ b/tests/schema/fail/example-examples.yaml @@ -0,0 +1,20 @@ +openapi: 3.1.1 + +# this example should fail, as example cannot be used together with examples. + +info: + title: API + version: 1.0.0 +components: + parameters: + animal: + name: animal + in: header + schema: {} + example: bear + examples: + a mammalian example: + value: bear + + +