Skip to content

Order is lost when generating the OpenAPI document #39

Description

@laurenceisla

The ordering of endpoints and other elements seem to be lost here and there when generating the OpenAPI document. For example, even though it's specified like this:

content := jsonb_build_object(
'application/json',
oas_media_type_object(
schema := oas_schema_object(
type := 'array',
items := oas_build_reference_to_schemas(table_name)
)
),
'application/vnd.pgrst.object+json',
oas_media_type_object(
schema := oas_build_reference_to_schemas(table_name)
),
'application/vnd.pgrst.object+json;nulls=stripped',
oas_media_type_object(
schema := oas_build_reference_to_schemas(table_name)
),
'text/csv',
oas_media_type_object(
schema := oas_schema_object(
type := 'string',
format := 'csv'
)
)
)

The text/csv entry always appears as first element of the object, even though it's defined as the last. This is because:

jsonb does not preserve white space, does not preserve the order of object keys, and does not keep duplicate object keys.
Source

A solution would be to use json instead of jsonb with the drawback of losing the ability to use some operations like concatenation || that is heavily used.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions