apple / apple/swift-openapi-generator
Consider changing configuration to not pretty-print JSON by default
- Dominant language
- Swift
- Stars
- 2k
- Forks
- 182
- Avg merge
- 13h 28m
- Merged PRs (30d)
- 5
Description
### 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_
Contributor guide
Research direction
Start by reading Sources/OpenAPIRuntime/Conversion/Configuration.swift around line 165, where the JSON configuration referenced in the issue is defined. Review the surrounding configuration and the discussion before determining whether pretty-printing should remain the default. Done means the project has a documented decision on the default behavior and any resulting changes are covered by the relevant project checks.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- swift
- Domain
- api
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100