Summary
OpenApiSchema.Examples currently serializes only for OpenAPI 3.1+ as the JSON Schema examples keyword. For OpenAPI 2.0 and 3.0, plural schema examples are omitted instead of being preserved as a JSON Schema compatibility extension.
Expected behavior
Schema-level example fields should serialize as follows:
example singular serializes as example for OpenAPI 2.0, 3.0, and 3.1+.
examples plural serializes as examples for OpenAPI 3.1+.
examples plural serializes as x-jsonschema-examples for OpenAPI 2.0 and 3.0.
Current behavior
example singular is serialized as example in all versions.
examples plural is written from OpenApiSchema.WriteJsonSchemaKeywords, which is only called for OpenAPI 3.1+.
- The OpenAPI 3.0 JSON Schema compatibility path writes other
x-jsonschema-* keywords, but does not write Examples.
- The OpenAPI 2.0 schema serialization path also does not write
Examples.
Notes
The existing x-examples constant/behavior appears to apply to parameter/response example maps, not schema-level JSON Schema examples. Schema-level plural examples should use x-jsonschema-examples when down-converting to OpenAPI 2.0 or 3.0.
Summary
OpenApiSchema.Examplescurrently serializes only for OpenAPI 3.1+ as the JSON Schemaexampleskeyword. For OpenAPI 2.0 and 3.0, plural schema examples are omitted instead of being preserved as a JSON Schema compatibility extension.Expected behavior
Schema-level example fields should serialize as follows:
examplesingular serializes asexamplefor OpenAPI 2.0, 3.0, and 3.1+.examplesplural serializes asexamplesfor OpenAPI 3.1+.examplesplural serializes asx-jsonschema-examplesfor OpenAPI 2.0 and 3.0.Current behavior
examplesingular is serialized asexamplein all versions.examplesplural is written fromOpenApiSchema.WriteJsonSchemaKeywords, which is only called for OpenAPI 3.1+.x-jsonschema-*keywords, but does not writeExamples.Examples.Notes
The existing
x-examplesconstant/behavior appears to apply to parameter/response example maps, not schema-level JSON Schemaexamples. Schema-level plural examples should usex-jsonschema-exampleswhen down-converting to OpenAPI 2.0 or 3.0.