Reconsider closed enums for string values decoded from API responses
Los mantenedores suelen responder en 3 días
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Aptitud para principiantes
- 35/100
- Tipo de issue
- Nueva funcionalidad
- Claridad
- Necesita aclaración
- Estado de actividad
- Activo
- Stack tecnológico
- openapi, swift
- Área
- api, backend-api-design
Línea de trabajo
Start by reading the response-side enum examples and the four options in the issue, especially the 16 generated StatusPayload enums and Batch.StatusPayload. Compare how the Swift generator handles the proposed anyOf pattern with the Java and Python examples cited. The issue is done when a direction is chosen for existing and future response enums, including whether it applies generally or only to selected fields.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
swift-openapi-generator turns every string enum in the spec into a closed @frozen Swift enum. Many of these types are public, through Components.Schemas or typealiases such as ResponseObject.Status. That has different consequences for values we send and values we decode.
Values we send (request side)
When OpenAI adds a value, a closed enum costs two things:
- The API-breakage check flags the new case, and we allowlist it with a changelog entry (as in
c5d14f7). CONTRIBUTING already lists new enum cases as an accepted additive change. - Users can't send the new value until we regenerate and release.
Neither is a real problem.
Values we decode (response side)
If the API returns a value the enum doesn't know, decoding throws and the whole call fails. That would hit already-shipped apps, which no SDK release can fix. Examples:
ResponseObject.Status(Components.Schemas.Response.Value3Payload.StatusPayload)Components.Schemas.Batch.StatusPayload, exposed directly by the Batch API (MacPaw/OpenAI#401)- 16 generated
StatusPayloadenums in total, plus other response-side enums
Java models every string enum as an open type: known constants plus an _UNKNOWN member, including Batch.Status. Python uses Literal types, which don't fail on unknown values at runtime.
Options
- Keep closed enums. This is what happens today. The risk is low per field, but a failure takes down every call that returns the field.
- Hand-written open types in
Edited/orFacade/. For example, aRawRepresentablestruct with static constants for the fields that matter most, like statuses. - Decode unknown values tolerantly. For example, a
ParsingOptionsflag or a custominit(from:)that maps unknown raw values to a fallback. This needs anunknown-style case, which generated enums don't have. - Use the generator's open-enum pattern. Rewrite selected schemas in
prepare_openapi.pyasanyOf: [<enum>, {type: string}], which swift-openapi-generator turns into a struct with a known-value field and a raw-string fallback.
To decide
- Whether response-side enums should be open in general, or only for selected fields such as statuses.
- Which option to use, and whether it applies to existing types (a public API change) or only to new ones.
- Lenguaje dominante
- Swift
- Estrellas
- 2.9k
- Forks
- 519
- Merge medio
- 4 d 9 h
- PR fusionados (30 d)
- 13
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de MacPaw/OpenAI
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
Los mantenedores suelen responder en 3 días
-
Enable batch promptsAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
MacPaw/OpenAI#73 · 1 comentario · 1 reacción ·
Los mantenedores suelen responder en 3 días
-
Check the HTTP status code for JSON responsesPosiblemente ocupada @mvanhorn la tomó hace 2 días. Abierto
Dificultad 4/5 3-5 días Aptitud para principiantes 48/100
MacPaw/OpenAI#469 · 1 comentario ·
Los mantenedores suelen responder en 3 días
-
Dificultad 4/5 3-5 días Aptitud para principiantes 55/100
Los mantenedores suelen responder en 3 días
-
Add Batch API supportAbierto
Dificultad 5/5 Más de una semana Aptitud para principiantes 35/100
Los mantenedores suelen responder en 3 días
Todos los issues de MacPaw/OpenAI
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
Los mantenedores suelen responder en 1 día
-
[BUG] File transcription skips audio chunks shorter than one secondPosiblemente ocupada @sabbah13 la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
altic-dev/FluidVoice#1161 ·
Los mantenedores suelen responder en 1 día
-
swift.md: `Date(myString, strategy: .iso8601)` example omits `try` — the initializer is throwingAbierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 88/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
githubnext/desktop-tools#25 ·
Los mantenedores suelen responder en 1 día
-
core: RAC_LLM_OPTIONS_DEFAULT.min_p disagrees with the IDL's annotated defaultPosiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. Abiertobug core p3
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
RunanywhereAI/runanywhere-sdks#1083 ·
Los mantenedores suelen responder en 5 días