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] Helidon MP generators incorrect apply @Pattern to byte[] property #19345

Closed
5 of 6 tasks
tjquinno opened this issue Aug 12, 2024 · 0 comments · Fixed by #19346
Closed
5 of 6 tasks

[BUG] Helidon MP generators incorrect apply @Pattern to byte[] property #19345

tjquinno opened this issue Aug 12, 2024 · 0 comments · Fixed by #19346

Comments

@tjquinno
Copy link
Contributor

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

The Helidon MP generators incorrectly add a @Pattern annotation to a property of type byte[] whereas @Pattern only applies to String.

This causes runtime errors.

openapi-generator version

7.7.0

OpenAPI declaration file content or url
openapi: 3.0.0
servers:
  - url: 'http://format.helidon.io:8080/format'
info:
  description: >-
    This spec is mainly for testing Petstore server and contains fake endpoints,
    models. Please do not use this for any other purpose. For this sample, you can use the api key
    `special-key` to test the authorization filters. Special characters: "
    \
  version: 1.0.0
  title: OpenAPI Formatter
  license:
    name: Apache-2.0
    url: 'https://www.apache.org/licenses/LICENSE-2.0.html'
tags:
  - name: format
    description: Format tester
paths:
  /format:
    get:
      operationId: simple
      responses:
        "200":
          content: {}
          description: success
      tags:
        - format

components:
  schemas:
    format_test:
      properties:
        byte:
          format: byte
          pattern: "^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$"
          type: string
Generation Details

Here is the generation set-up in the project's automated sample generation format for Helidon v3:

generatorName: java-helidon-server
library: mp
outputDir: samples/server/others/java-helidon-server/v3/mp-format-test
inputSpec: modules/openapi-generator/src/test/resources/3_0/helidon/format-test.yaml
templateDir: modules/openapi-generator/src/main/resources/java-helidon/server
additionalProperties:
  helidonVersion: 3.2.7
  artifactId: format-helidon-server-mp
  hideGenerationTimestamp: "true"
  fullProject: "true"

And for Helidon v4:

generatorName: java-helidon-server
library: mp
outputDir: samples/server/others/java-helidon-server/v4/mp-format-test
inputSpec: modules/openapi-generator/src/test/resources/3_0/helidon/format-test.yaml
templateDir: modules/openapi-generator/src/main/resources/java-helidon/server
additionalProperties:
  helidonVersion: 4.0.11
  artifactId: format-helidon-server-mp
  hideGenerationTimestamp: "true"
  fullProject: "true"
Steps to reproduce
  1. Add the two above configuration yaml files as bin/configs/java-helidon-server-mp-X_format_test.yaml where the X in the middle is 3 for the first yaml file and 4 for the second.
  2. Run ./bin/generate-samples.sh ./bin/configs/java-helidon-server-mp_3_format_test.yaml ./bin/configs/java-helidon-server-mp_4_format_test.yaml.
  3. cat samples/server/others/java-helidon-server/v3/mp-format-test/src/main/java/org/openapitools/server/model/FormatTest.java and see the @Pattern annotation on getByte().
  4. Repeat in v4 instead of v3.
Related issues/PRs

See also #7153

Suggest a fix

Same fix as in the referenced PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant