Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Order is lost when generating the OpenAPI document #39

Open
laurenceisla opened this issue Feb 1, 2024 · 0 comments
Open

Order is lost when generating the OpenAPI document #39

laurenceisla opened this issue Feb 1, 2024 · 0 comments

Comments

@laurenceisla
Copy link
Member

laurenceisla commented Feb 1, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant