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

[BUG][JAVA][SPRING] Not able to generate code from spec file with webhooks definition #20175

Open
4 of 6 tasks
kcichonczyk-getmoss opened this issue Nov 25, 2024 · 0 comments
Open
4 of 6 tasks

Comments

@kcichonczyk-getmoss
Copy link

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

While trying to generate code from the yaml file using gradle (openApiGenerate), the task fails with the following error:
Cannot invoke "java.util.Map.get(Object)" because the return value of "io.swagger.v3.oas.models.Operation.getExtensions()" is null
it happens for the files that contain webhooks definition (check OpenApi declaration file section).

openapi-generator version

'org.openapi.generator' version '7.10.0'

OpenAPI declaration file content or url
openapi: 3.1.0
info:
  title: Webhook Example
  version: 1.0.0
  description: >
    Easy example of documentation with a single webhook,
    provided by OpenAPI Initiative.

webhooks:
  newPet:
    post:
      description: A new pet is born, let's come and discover it in Petstore.
      requestBody:
        description: Information about a new pet in the system
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/Pet"
      responses:
        "200":
          description: Return a 200 status to indicate that the data was received successfully
Generation Details

Just run any specification file that contains webhooks: definition with the gradle setup above.

Steps to reproduce
  1. use openApi spec file with webhooks definition,
  2. setup gradle task for codegen, like this:
openApiGenerate {
    generatorName.set("spring")
    library.set("spring-boot")

    inputSpec.set(specFile)
    outputDir.set(generatedSourcesOutputDir)

    apiPackage.set("dev.api")
    invokerPackage.set("dev.invoker")
    modelPackage.set("dev.model")

    additionalProperties.set([
            basePackage: "dev.integration", 
            useTags: true, 
            dateLibrary: "java8"
    ])
}
  1. run the task
Related issues/PRs

#13103

Suggest a fix

Implement null check here for extensions.

@kcichonczyk-getmoss kcichonczyk-getmoss changed the title [BUG][JAVA][SPRING] Not able to generate code with webhooks definition [BUG][JAVA][SPRING] Not able to generate code from spec file with webhooks definition Nov 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant