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

3.x Helidon OpenAPITools server generator seems to ignore requestBody/required #7686

Open
tjquinno opened this issue Sep 28, 2023 · 1 comment
Assignees
Labels
3.x Issues for 3.x version branch bug Something isn't working open-api-tools Tracking issues in OpenAPITools generator project P3

Comments

@tjquinno
Copy link
Member

tjquinno commented Sep 28, 2023

Environment Details

  • Helidon Version: 3.x
  • Helidon SE or Helidon MP
  • JDK version:
  • OS:
  • Docker version (if applicable):

Problem Description

The OpenAPITools generator seems to ignore the requestBody/required setting.

There might be a problem with the generator framework rather than with the Helidon generator(s). See OpenAPITools/openapi-generator#16561

This issue represents that we need to:

  • verify whether there needs to be a Helidon-specific fix for this, and
  • if not, track the openAPITools issue.

Steps to reproduce

  1. Download the greeting.yml.txt file attached to this issue and remove the .txt suffix. It is an OpenAPI document for the Helidon greeting app with the PUT operation's requestBody set to required: false.
  2. Download the generator following these instructions. Remember where you downloaded the generator.
  3. Run the generator:
java -jar ${path-to-generator}/openapi-generator-cli.jar \
  generate \
  -i greeting.yml \
  -g java-helidon-server \
  --library se \
  -p groupId=io.helidon.examples \
  -p artifactId=helidon-openapigen-se-server \
  -p artifactVersion=1.0.0-SNAPSHOT \
  -p apiPackage=io.helidon.examples.openapigen.se.server.api \
  -p modelPackage=io.helidon.examples.openapigen.se.server.model \
  -p invokerPackage=io.helidon.examples.openapigen.se.server
  1. The generated code returns 501 - not implemented for the endpoints (because after generator the developer typically customizes the code to implement the business logic), but we can reproduce the problem without revising the generated code.
    1. Build and run the generated project.
    mvn clean package
    java -jar target/helidon-openapigen-se-server.jar
    
    1. In another terminal window, run curl -v -X PUT -d "{ \"message\": \"Hola\" }" http://localhost:8080/greet/greeting which returns 501, also expected. This verifies that the generated server endpoint is invoked--that's what returns the 501.
    2. Same window, run curl -v -X PUT http://localhost:8080/greet/greeting. This does not set the request body which, according to the OpenAPI document, should not be required. The response is 500 - internal server error. The generated endpoint is not reached.
  2. Back in the original terminal window, you'll see exceptions because JacksonBodyReader is trying to process the missing content as it prepares to invoke the generated server endpoint.

greeting.yml.txt

@tjquinno tjquinno added bug Something isn't working 3.x Issues for 3.x version branch open-api-tools Tracking issues in OpenAPITools generator project labels Sep 28, 2023
@tjquinno tjquinno changed the title 3.x Tracking: OpenAPITools generator (and therefore the Helidon generators) seem to ignore requestBody/required 3.x Helidon OpenAPITools server generator seem to ignore requestBody/required Sep 28, 2023
@tjquinno tjquinno changed the title 3.x Helidon OpenAPITools server generator seem to ignore requestBody/required 3.x Helidon OpenAPITools server generator seems to ignore requestBody/required Sep 28, 2023
@m0mus m0mus added the P3 label Oct 5, 2023
@Captain1653
Copy link
Contributor

Looks like it's bug of the generator. There is some workaround in this comment .

Is it still should be checked?

@m0mus m0mus added this to Backlog Aug 12, 2024
@m0mus m0mus moved this to High priority in Backlog Aug 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.x Issues for 3.x version branch bug Something isn't working open-api-tools Tracking issues in OpenAPITools generator project P3
Projects
Status: High priority
Development

No branches or pull requests

3 participants