Skip to content

Consider changing configuration to not pretty-print JSON by default #768

Open
@Lukasa

Description

@Lukasa

Motivation

When debugging an issue with a solar inverter, I bumped into this default:

https://github.com/apple/swift-openapi-runtime/blob/e5b0de7221dd1a0c9b9a6de9afdbe06f3e46a24f/Sources/OpenAPIRuntime/Conversion/Configuration.swift#L165

As it turns out, the issue with this inverter was that it did not handle pretty-printed JSON. This cost me about 30 minutes of debugging time as I tried to root-cause why the curl equivalent of my command worked, but the swift-openapi-generator equivalent didn't.

In general, I was surprised to see swift-openapi-generator defaulting to pretty-printing JSON. While the default of sortedKeys makes some sense to me (certain tests are easier to write), the pretty-printed default seems to me to have more downsides with fewer obvious upsides. Most notably, it diverges from common practice in JSON-encoding libraries, which tend to default to minified JSON and require user action to prettify it.

Proposed solution

It seems to me that the community should at least consider whether the default behaviour here should be flipped.

Alternatives considered

No response

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/runtimeAffects: the runtime library.kind/enhancementImprovements to existing feature.size/SSmall task. (A couple of hours of work.)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions