[BUG][C#] Generic host loses object oneOf values during serialization

Abierto
#25,547 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

  • #25549 de @AndreyVMarkelov — cerrado sin fusionar

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
25/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Estancado
Stack tecnológico
csharp
Área
devtools

Línea de trabajo

Reproduce with the generation command and the spec in the issue, then deserialize {"name":"a","size":2} to Entry using the JsonSerializerOptions from the generated HostConfiguration and serialize it back. Linked pull request #25549 is already open against this bug, so review it before starting. Done means the round trip keeps name and size and the output is no longer {}.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Bug Report Checklist
  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator?
  • 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?
Description

The C# generichost client serializes an object oneOf without a discriminator to {}, losing the selected variant's properties.

openapi-generator version

Reproduced on master 57edb417ea3fb15de7bc523a133c9cc016acab19 (7.28.0-SNAPSHOT).

OpenAPI declaration file content
openapi: 3.0.3
info:
  title: oneOf reproduction
  version: 1.0.0
paths: {}
components:
  schemas:
    Entry:
      oneOf:
        - $ref: '#/components/schemas/FileEntry'
        - $ref: '#/components/schemas/FolderEntry'
    FileEntry:
      type: object
      required: [name, size]
      properties:
        name:
          type: string
        size:
          type: integer
    FolderEntry:
      type: object
      required: [name, id]
      properties:
        name:
          type: string
        id:
          type: string
Generation Details
java -jar openapi-generator-cli.jar generate -g csharp --library generichost -i spec.yaml -o client --additional-properties=packageName=OneOfRepro
Steps to reproduce

With JsonSerializerOptions configured by generated HostConfiguration, deserialize {"name":"a","size":2} to Entry, then serialize it. Expected: the same object. Actual: {}.

Related issues/PRs

No matching issue found.

Suggest a fix

Write the active object variant's properties when serializing an object oneOf without a discriminator, preserving any properties declared on the wrapper.

Lenguaje dominante
Java
Estrellas
26.9k
Forks
7.8k
Merge medio
2 d 10 h
PR fusionados (30 d)
180

Preparar el entorno

Abrir en Codespaces

Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de OpenAPITools/openapi-generator

Todos los issues de OpenAPITools/openapi-generator

Issues similares

Más issues de Java

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.