OpenAPITools / OpenAPITools/openapi-generator
[BUG] swift-combine doesn't escape '#' in enum variables
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Bug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
- Have you validated the input using an OpenAPI validator (example)?
- Have you tested with the latest master to confirm the issue still exists?
- Have you searched for related issues/PRs?
- What's the actual output vs expected output?
- [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
Some of the enums values we have are full URLs, from which the swift5 generator correctly replaces # with Hash, however the swift-combine generator does not replace them.
openapi-generator version
7.2.0
OpenAPI declaration file content or url
openapi: 3.0.3
info:
title: authentik
version: 2023.10.4
description: Making authentication simple.
contact:
email: hello@goauthentik.io
license:
name: MIT
url: https://github.com/goauthentik/authentik/blob/main/LICENSE
paths: {}
components:
schemas:
DigestAlgorithmEnum:
enum:
- http://www.w3.org/2000/09/xmldsig#sha1
- http://www.w3.org/2001/04/xmlenc#sha256
- http://www.w3.org/2001/04/xmldsig-more#sha384
- http://www.w3.org/2001/04/xmlenc#sha512
type: string
Generation Details
docker run \
-v $(pwd):/local \
docker.io/openapitools/openapi-generator-cli:v7.2.0 generate \
-i /local/schema.yml \
-g swift-combine \
-o /local \
-c /local/config.yaml
Config being
templateDir: /local/templates/
additionalProperties:
disallowAdditionalPropertiesIfNotPresent: false
enumUnknownDefaultCase: true
projectName: authentikClient
podAuthors: authentik Team
podHomepage: https://goauthentik.io/
podSummary: authentik Swift API Client
files:
README.mustache:
templateType: SupportingFiles
destinationFilename: README.md
Steps to reproduce
Run the command above with the supplied schema, which will generate this swift file:
public enum DigestAlgorithmEnum: String, Codable, CaseIterable {
case _200009xmldsig#sha1 = "http://www.w3.org/2000/09/xmldsig#sha1"
case _200104xmlenc#sha256 = "http://www.w3.org/2001/04/xmlenc#sha256"
case _200104xmldsigMore#sha384 = "http://www.w3.org/2001/04/xmldsig-more#sha384"
case _200104xmlenc#sha512 = "http://www.w3.org/2001/04/xmlenc#sha512"
case unknownDefaultOpenApi = "unknown_default_open_api"
}
, which is not syntactically correct.
Related issues/PRs
Suggest a fix
This can be worked around with this enum mapping:
enumNameMappings:
2000/09/xmldsig#sha1: _2000_09_xmldsig_sha1
2001/04/xmldsig-more#sha384: _2001_04_xmldsig-more_sha384
2001/04/xmlenc#sha256: _2001_04_xmlenc_sha256
2001/04/xmlenc#sha512: _2001_04_xmlenc_sha512
however this shouldn't be required imo
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the supplied Docker command with the provided OpenAPI schema and compare the generated swift-combine enum with the reported output. Done means the generated Swift enum cases are syntactically valid while preserving the original URL values, without requiring enumNameMappings.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- swift
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100