Skip to content

[BUG][CSharp] Root webhooks element generates code that does not compile #20928

@JamieDavidsonLiberis

Description

@JamieDavidsonLiberis

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • 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?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

CSharp code generator creates code that does not compile for webhooks using OpenAPI 3.1's webhooks root object.

The yaml posted below generates the following code:

/// <summary>
/// The <see cref="IHelloWorldPostApiResponse"/>
/// </summary>
public interface IHelloWorldPostApiResponse : Org.OpenAPITools.Client.IApiResponse
{
    /// <summary>
    /// Returns true if the response is 204 
    /// </summary>
    /// <returns></returns>
    bool Is { get; }

    /// <summary>
    /// Returns true if the response is 500 
    /// </summary>
    /// <returns></returns>
    bool Is { get; }
}
openapi-generator version

7.12.0

OpenAPI declaration file content or url
openapi: 3.1.0
info:
  title: Minimal reproduction for csharp webhook bug
  version: 1.0.0
  description: This is an example API to reproduce a bug with webhooks in csharp codegen
tags:
  - name: Test
    description: This is a test
webhooks:
  helloWorld:
    post:
      summary: Example webhook
      responses:
        "204":
          description: Webhook processed
        "500":
          description: Webhook not processed
      description: Send when an example is needed
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                message:
                  type: string
              description: The payload of the HelloWorld webhook
        description: Contains the details of the hello world webhook
Generation Details

Running the CLI command using the wrapper from https://github.com/OpenAPITools/openapi-generator-cli. No extra config.

Steps to reproduce

Running openapi-generator-cli generate -g csharp -i "./WebhooksTest.yaml" -o "./WebhooksTest" against the yaml above.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions