Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generated HttpValidationProblemDetails does not serialize AdditionalData properly #5888

Closed
hoekstrit opened this issue Dec 10, 2024 · 1 comment · Fixed by #5891
Closed
Assignees
Labels
type:bug A broken experience WIP
Milestone

Comments

@hoekstrit
Copy link

hoekstrit commented Dec 10, 2024

What are you generating using Kiota, clients or plugins?

API Client/SDK

In what context or format are you using Kiota?

Nuget tool

Client library/SDK language

None

Describe the bug

I'm trying to generate a client project with Kiota version 1.20.0. The client is generated, but I'm having some issues with the generated models for the ProblemDetails and HttpValidationProblemDetails. When using the client ProblemDetails it will contain traceId in the AdditionalData property. HttpValidationProblemDetails has the AdditionalData property, but it's not filled with the traceId

I've generated my openapi.json by using NSwag.MSBuild version 14.1.0.

ProblemDetails are generated with additionalProperties available.

"ProblemDetails": {
  "type": "object",
  "additionalProperties": {
    "nullable": true
  },
  "properties": {
    "type": {
      "type": "string",
      "nullable": true
    },
    "title": {
      "type": "string",
      "nullable": true
    },
    "status": {
      "type": "integer",
      "format": "int32",
      "nullable": true
    },
    "detail": {
      "type": "string",
      "nullable": true
    },
    "instance": {
      "type": "string",
      "nullable": true
    }
  }
}

HttpValidationProblemDetails are generated with allOf from ProblemDetails. It's generated with additionalProperties as well.

"HttpValidationProblemDetails": {
  "allOf": [
    {
      "$ref": "#/components/schemas/ProblemDetails"
    },
    {
      "type": "object",
      "additionalProperties": {
        "nullable": true
      },
      "properties": {
        "errors": {
          "type": "object",
          "additionalProperties": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      }
    }
  ]
},

I've generated my client using the following kiota command with `KIOTA_OFFLINE_ENABLED=true'.

dotnet kiota generate --openapi ./openapi.json -l CSharp -o GeneratedClient -c KiotaApiClient -n Kiota.Api.Client --clean-output

Both models have the AdditionalData property, but HttpValidationProblemDetails does not implement the IAdditionalDataHolder interface.

Expected behavior

I expect both ProblemDetails and HttpValidationProblemDetails to contain traceId when using the client.

How to reproduce

Start both Kiota.Apiand Kiota.App from the example repository. The console application will run the following two scenarios.

  • Post WeatherForecast with response status code 500 and type ProblemDetails
  • Post WeatherForecast with response status code 400 and type HttpValidationProblemDetails

Result of the Console.App should be this output:

ProblemDetails scenario
Response:
{"type":"https://tools.ietf.org/html/rfc9110#section-15.6.1","title":"An error occurred while processing your request.","status":500,"traceId":"00-3317e8563c0d629863406ae8e054f647-c8a5fe0ddabb2513-00"}
TraceId: 00-3317e8563c0d629863406ae8e054f647-c8a5fe0ddabb2513-00


HttpValidationProblemDetails scenario
Response:
{"type":"https://tools.ietf.org/html/rfc9110#section-15.5.1","title":"One or more validation errors occurred.","status":400,"errors":{"Summary":["The Summary field is required."]},"traceId":"00-3c024662c4db06855d607e4e234044c3-4fa6227bfa644646-00"}
TraceId:

Open API description file

openapi.json

Kiota Version

1.20.0

Latest Kiota version known to work for scenario above?(Not required)

No response

Known Workarounds

No response

Configuration

No response

Debug output

Click to expand log ```
</details>


### Other information

_No response_
@hoekstrit hoekstrit added status:waiting-for-triage An issue that is yet to be reviewed or assigned type:bug A broken experience labels Dec 10, 2024
@github-project-automation github-project-automation bot moved this to Needs Triage 🔍 in Kiota Dec 10, 2024
@baywet baywet self-assigned this Dec 10, 2024
@baywet baywet moved this from Needs Triage 🔍 to In Progress 🚧 in Kiota Dec 10, 2024
@baywet baywet added this to the Kiota v1.22 milestone Dec 10, 2024
@baywet baywet removed the status:waiting-for-triage An issue that is yet to be reviewed or assigned label Dec 10, 2024
@baywet
Copy link
Member

baywet commented Dec 10, 2024

Hi @hoekstrit
Thank you for using kiota and for reaching out.

I believe this was attempted to be fixed in #2604 but the fix only partially worked.

I put together #5891 to address the bug.

@github-project-automation github-project-automation bot moved this from In Progress 🚧 to Done ✔️ in Kiota Dec 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:bug A broken experience WIP
Projects
Status: Done ✔️
Development

Successfully merging a pull request may close this issue.

2 participants