[BUG][rust-axum] Range response codes (4XX, 5XX) generate code that does not compile
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
- #25294 de @teovillanueva — cerrado sin fusionar
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- Medio día
- Aptitud para principiantes
- 35/100
Línea de trabajo
Start with server-operation.mustache and the generated response enum for the provided OpenAPI declaration, then reproduce the failures by generating the rust-axum server and running cargo check in out. Done means ranged response variants preserve a concrete u16 status with optional body/headers as appropriate, and generated servers compile and build responses using the status() builder.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Description
When an operation declares a range response code (4XX, 5XX, ...), the rust-axum server generator emits code that does not compile. For range responses, server-operation.mustache renders
response.status::<u16>(body.code.parse().unwrap()); // 4XX
which assumes the response body has a code field (error[E0609]: no field 'code' on type 'models::Error'), fails when the response has no body (error[E0425]: cannot find value 'body' in this scope), and drops the builder returned by status() (error[E0382] once the other errors are worked around). The generated response enum also has no way for the implementation to choose the concrete status within the range.
openapi-generator version
master (7.27.0-SNAPSHOT, commit 30f13393)
OpenAPI declaration file content or url
openapi: 3.0.3
info:
title: Range responses
version: 1.0.0
paths:
/pets/{petId}:
get:
operationId: getPet
parameters:
- name: petId
in: path
required: true
schema:
type: integer
format: int64
responses:
"200":
description: The pet
content:
application/json:
schema:
$ref: "#/components/schemas/Pet"
"4XX":
description: Client error
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
"5XX":
description: Server error
components:
schemas:
Pet:
type: object
properties:
name:
type: string
Error:
type: object
properties:
message:
type: string
Generation Details
java -jar openapi-generator-cli.jar generate -g rust-axum -i spec.yaml -o out
Steps to reproduce
- Generate the server with the spec above.
- Run
cargo checkinout. - Compilation fails with E0609 (
no field 'code' on type 'models::Error') for the4XXarm and E0425 (cannot find value 'body') for the5XXarm.
Related issues/PRs
None found.
Suggest a fix
Have range responses carry the status code: generate them as struct variants with a status: u16 field (plus body and headers as usual), e.g. Status4XX_ClientError { status: u16, body: models::Error }. The server then sets response.status(status), so the implementation picks the concrete code within the range.
- Lenguaje dominante
- Java
- Estrellas
- 26.9k
- Forks
- 7.8k
- Merge medio
- 2 d 23 min
- PR fusionados (30 d)
- 177
Preparar el entorno
Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.
- Incluye un Dockerfile o un 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 OpenAPITools/openapi-generator
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
OpenAPITools/openapi-generator#25768 ·
Los mantenedores suelen responder en 1 día
-
Enhancement: Feature
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
OpenAPITools/openapi-generator#25753 ·
Los mantenedores suelen responder en 1 día
-
[BUG][RUBY-NEXTGEN] A non-String value in a pattern-constrained attribute raises NoMethodErrorPosiblemente ocupada @Inf1mum la tomó hace 2 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
OpenAPITools/openapi-generator#25724 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
[BUG][RUBY-NEXTGEN] Response#to_hash is advertised and raises when the data is an ArrayPosiblemente ocupada @Inf1mum la tomó hace 2 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 77/100
OpenAPITools/openapi-generator#25723 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
[BUG][RUBY-NEXTGEN] A JSON string response raises ApiError because the body is parsed twicePosiblemente ocupada @Inf1mum la tomó hace 2 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 77/100
OpenAPITools/openapi-generator#25719 · 1 comentario ·
Los mantenedores suelen responder en 1 día
Todos los issues de OpenAPITools/openapi-generator
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
eclipse-tradista/tradista#371 ·
Los mantenedores suelen responder en 1 día
-
Failed to start Rescue missionAbiertocritical
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
mars-sim/mars-sim#2199 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
[BUG-02] Endpoints /assistente/relatorio/*/preview retornam 404 ("Ver na tela" dos relatórios)Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
projeto-ong-amar/projeto-ong-amar-backend#26 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
primefaces/primefaces#15568 ·
Los mantenedores suelen responder en 1 día
-
崩溃日志只按 CRLF 分行Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
PCL-Community/PCL-CE#3872 ·
Los mantenedores suelen responder en 1 día