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

Aberta
#25,547 0 comentários 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 1 dia

Ninguém assumiu esta issue ainda.

  • #25549 de @AndreyVMarkelov — fechado sem integrar

Avaliação

Dificuldade
3/5
Tempo estimado
1-2 dias
Facilidade para iniciantes
25/100
Tipo de issue
Bug
Clareza
Claramente especificada
Status de atividade
Estagnada
Stack de tecnologia
csharp
Domínio
devtools

Direção de pesquisa

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 {}.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

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.

Linguagem predominante
Java
Estrelas
26.9k
Forks
7.8k
Merge médio
2d 10h
PRs com merge (30d)
180

Preparar o ambiente

Abrir no Codespaces

Inicia o contêiner de desenvolvimento do projeto no navegador, com a sua própria conta do GitHub.

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de OpenAPITools/openapi-generator

Todas as issues de OpenAPITools/openapi-generator

Issues semelhantes

Mais issues de Java

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.