Skip to content

[BUG] [Dart, 7.13.0] allOf loses list type information in referred properties. #21340

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

Closed
allComputableThings opened this issue May 28, 2025 · 4 comments

Comments

@allComputableThings
Copy link

openapi: 3.0.0
info:
  title: Sample API
  description: API description in Markdown.
  version: 1.0.0
paths:
  /garden:
    get:
      summary: Return the path
      responses:
        200:
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Path'

components:
  schemas:

    Points:
      properties:
        x:
          items:
            type: float
          type: array
        y:
          items:
            type: float
          type: array
      required:
      - x
      - y
      type: object

    Path:
      allOf:
        - $ref: '#/components/schemas/Points'    
      properties:
        id:
          type: integer
        meta:
          default: ''
          type: string
      required:
        - id
        - meta
      type: object

gives:


class Path {
...
  List<String> x;     // Should be List<int>
  List<String> y;

Reproduces with:


java -jar openapi-generator-cli-7.13.0.jar generate -i problem.yaml -g dart -o ./_swagger --additional-properties=pubLibrary=flutter_common_openapi,pubName=flutter_common_openapi

@wing328
Copy link
Member

wing328 commented May 28, 2025

can you try enabling the rule REFACTOR_ALLOF_WITH_PROPERTIES_ONLY in openapi normalizer?

https://github.com/openapitools/openapi-generator/blob/master/docs/customization.md#openapi-normalizer

@allComputableThings
Copy link
Author

java -jar openapi-generator-cli-7.13.0.jar generate -i problem.yaml -g dart -o ./_swagger --additional-properties=pubLibrary=flutter_common_openapi,pubName=flutter_common_openapi --openapi-normalizer REFACTOR_ALLOF_WITH_PROPERTIES_ONLY=true

... makes no difference.

Also the following is the same:

    Path:
      allOf:
        - $ref: '#/components/schemas/Points'
        - type: object
          properties:
            id:
              type: integer
            meta:
              default: ''
              type: string
          required:
          - id
          - meta

@wing328
Copy link
Member

wing328 commented May 28, 2025

        x:
          items:
            type: float
          type: array

that's not correct

float should be defined as the following according to the spec

        x:
          items:
            type: number
            format: float
          type: array

@allComputableThings
Copy link
Author

Makes sense. Thank you.
Would be nice if spec errors like this could cause a warning.

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

2 participants