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

Add sopSwaggerGenericToEncodingWithOpts and use it. #27

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

kosmikus
Copy link

The ToJSON Schema instance is missing an explicit definition of toEncoding. Without an explicit definition, the default definition kicks in, but the default loses ordering information of JSON object fields. This means that in resulting OpenAPI schemas, field names of JSON objects appear in essentially random order rather than the order specified in Haskell code.

The reason is that this ToJSON instance makes use of a somewhat special sopSwaggerGenericToJSONWithOpts function that is not used anywhere else and that had no counterpart for Encoding.

Such a counterpart is added here.

This is a relatively ad-hoc fix. This code looks like it might benefit from additional refactoring, but if at all, I think that should probably be done in a different MR.

See also haskell-servant/servant-swagger-ui#89 which is an orthogonal problem with losing the order of fields.

The ToJSON Schema instance is missing an explicit definition of
toEncoding, which this patch adds.

The reason is that this ToJSON instance makes use of a somewhat
special sopSwaggerGenericToJSONWithOpts function that is not used
anywhere else and that had no counterpart for Encoding.

Such a counterpart is added here.
@arybczak
Copy link
Contributor

arybczak commented Jul 5, 2022

Ping. Can this be merged?

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

Successfully merging this pull request may close these issues.

2 participants