There is still some awkward spots here IMHO, so I would like to discuss it.
(Note that for the sake of discussion I simplified some types here)
A single parameter of type T can have an example in 4 places:
parameter.example of type T
parameter.examples of {[index: string]: { value: T}}
parameter.schema.example of type T
parameter.schema.examples of type T[]
We do few major things with those in http-spec:
- We place
parameter.schema.example in `parameter.schema.examples' (essentially overwriting it if exists, I believe?)
- We place
parameter.example in parameter.schema.example (again, overwriting, if the latter exists)
- After my change we place
parameter.example in parameter.examples (by appending, not overwriting)
All those things combined lead to funny behaviour.
To make sure I gathered all possible examples, I have to do [...parameter.examples, ...parameter.schema.examples]. This is a problem in itself btw, I shouldn't be forced to concatenate stuff to get all the possible examples.
But on top of that, because parameter.example lands both in parameter.examples (by 3) and parameter.schema.examples (by 2 followed by 1), it leads to having doubled examples on the list, when parameter.example is utilised in the original schema.
Proposal
Therefore I propose to cut this complex logic, and simply put all the parameters described above on a single parameters.examples list, while leaving the schema untouched. It would essentially concatenate all 4 example types into one. http-spec users should only access examples via parameters.examples and all examples should be available there.
The one problem that comes to my mind would be naming. Especially names from parameter.schema.examples would have to be generated, as this property is just a list of values. I guess something like schema example 1... could be generated automatically.
There is still some awkward spots here IMHO, so I would like to discuss it.
(Note that for the sake of discussion I simplified some types here)
A single parameter of type T can have an example in 4 places:
parameter.exampleof type Tparameter.examplesof{[index: string]: { value: T}}parameter.schema.exampleof type Tparameter.schema.examplesof type T[]We do few major things with those in http-spec:
parameter.schema.examplein `parameter.schema.examples' (essentially overwriting it if exists, I believe?)parameter.exampleinparameter.schema.example(again, overwriting, if the latter exists)parameter.exampleinparameter.examples(by appending, not overwriting)All those things combined lead to funny behaviour.
To make sure I gathered all possible examples, I have to do
[...parameter.examples, ...parameter.schema.examples]. This is a problem in itself btw, I shouldn't be forced to concatenate stuff to get all the possible examples.But on top of that, because
parameter.examplelands both inparameter.examples(by 3) andparameter.schema.examples(by 2 followed by 1), it leads to having doubled examples on the list, whenparameter.exampleis utilised in the original schema.Proposal
Therefore I propose to cut this complex logic, and simply put all the parameters described above on a single
parameters.exampleslist, while leaving the schema untouched. It would essentially concatenate all 4 example types into one.http-specusers should only access examples viaparameters.examplesand all examples should be available there.The one problem that comes to my mind would be naming. Especially names from
parameter.schema.exampleswould have to be generated, as this property is just a list of values. I guess something likeschema example 1... could be generated automatically.