I want to take a moment to offer a left-of-field suggestion.
Rather than any automatic mapping to any pretty names, which, as folks have pointed out, will present some opportunity for conflicts, we could instead provide just the hex encoding—which is much less likely to conflict with other handwritten identifiers.
Support for structured preprocessing the OpenAPI document
Then if folks don't like what they get I'm proposing we offer a different solution which has some more general benefits (which I'll explain after).
We could allow for adopters to provide a list of JSON Patches to apply to the OpenAPI document before generation.
JSON Patch is outlined in RFC-6902 and is a good fit for this kind of operation and allows for modifications of keys and values based on their JSON path.
One notable use of this is in Kustomize: a tool extensively used in the Kubernetes ecosystem for managing and composing lots of YAML—so much so they upstreamed the functionality into Kubectl. There's also a more accessible primer at jsonpatch.com.
We could extend the schema for the plugin config file to provide an array of such patches:
# openapi-generator-config.yaml
...
patches:
- op: replace
path: "/paths//foo/get/operationId"
value: "getFoo"
- op: move
from: "/components/headers/my header"
path: "/components/headers/MyHeader"
This would transform the following OpenAPI document...
# openapi.yaml
paths:
/foo:
get:
operationId: get+foo
components:
headers:
my header:
schema:
type: string
...into...
# openapi.yaml
paths:
/foo:
get:
operationId: getFoo
components:
headers:
MyHeader
schema:
type: string
Our tool could take care of rewriting any references to moved values.
Additional benefits
I suggest that it's better to maintain the changes to the OpenAPI document in this manner because the input to the pipeline is still the unaltered document as published by the service maintainer.
It also allows for the correction or removal of problematic parts of the spec, using the remove
JSON Patch operation.
Patching out parts of the spec can also be useful while we are still filling out support for OpenAPI features, as it allows adopters to make use of part of an OpenAPI document, until those features are supported by Swift OpenAPI Generator.