Closed RobinTail closed 11 months ago
The examples
you refer to, are NOT the property of SchemaObject
.
This is the examples
property of ComponentsObject, @kkolstad
Anyway, thank you very much for responding.
@pjmolina , it seems that the changes made by #124 are wrong, because the property examples
exists in multiple interfaces. In most cases it's really the ExampleObject
, but within the SchemaObject
examples
still has to be an array.
I'm suggesting to revert #124 .
@RobinTail I see my mistake now. Thanks for pointing that out. Sorry for the bug 😄
Thansk for the analysis @RobinTail
Hey @kkolstad when I read the Open API spec 3.1, i see that ParameterObject has a examples
field that can be set to Map[ string, Example Object | Reference Object]
How do i use this type to add examples to my Open Api spec ?
Best
Regarding the particular examples
in ParameterObject you refer to, @vafanassieff:
What they call Map
is a Record
in Typescript.
So you assign examples
with object having keys as string
and values as ExampleObject | ReferenceObject
...
examples: {
example1: {
value: "something"
}
}
See the definition of ExampleObject
here:
https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#example-object
It's typed correctly in the library and not related to this issue.
Using the recent version (4.2.0) I'm getting OpenAPI 3.1 validation error regarding SchemaObject's
examples
being object instead of array.It's caused by the changes in this PR: https://github.com/metadevpro/openapi3-ts/pull/124 In that PR
examples
were changed fromany[]
toExamplesObject
.The specification refers to this document: https://datatracker.ietf.org/doc/html/draft-bhutton-json-schema-validation-00#page-22 which as well as the validator says that
examples
must be array.I'm trying to find the source of truth and/or where the mistake is.
@kkolstad || @pjmolina , could you tell me please which information the changes from #124 are based on? Is there any other RFC or revision that changed the
examples
from array to object? Is that an issue of the validator or of the PR?