Fields order in OpenAPI Specification
Hi!
I have the next documentation section in my test:
...
.responseFields(
fieldWithPath("albums").description("Result list of requested albums"),
fieldWithPath("albums[].id").description("Album id, f.e. 59727856"),
fieldWithPath("albums[].barcodeId").description("Album's barcode id (EAN-13 or UPC-A)").optional(),
...
)
...
while OpenAPI Spec has the next relevant section:
...
components:
schemas:
albums629762604:
type: object
properties:
albums:
type: array
description: Result list of requested albums
items:
type: object
properties:
copyright:
type: string
description: Album's copyright information
releaseDate:
type: string
description: Album's release date (ISO-8601)
numberOfVolumes:
type: number
description: Number of volumes
...
...
which doesn't match the order in my test.
I do understand that from the structural point of view this is not a problem at all, but it is important when you trying to generate some static web pages based on Open API Spec. And there you may see fields in some non-logical order.
I do appreciate any feedback and your thoughts in this regard!
Thanks in advance!
Hey @aliaksei-taliuk ,
yes, afaik the supported spec formats don't require any property order nor imply semantics with the ordering.
Spring Restdocs values the order in which fields are documented for the generated HTML docs, so maybe we should do the same. The current "shuffleing" probably stems from use of HashMaps/HashSets (over insertion-order-stable LinkedHashMaps, LinkedHashSets) or the Kotlin equivalents.
Thanks for the reply! This enhancement would be much appreciated!
I am also experiencing the same issue and I don't understand how to solve it. The latest version is 1.9.0.
The yaml is not created in the order of FieldDescriptor entered in requestFields of the test code.
I am not using Map or Set. What should I do?
I also attach the code and result screen.
< Test Code >
< Result >