Skip to content

[BUG][DART-DIO] Invalid generics for additionalProperties without type #23645

@brettkail-wk

Description

@brettkail-wk

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator?
  • 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

Model property with additionalProperties: {...} but without type: object producing BuildMap with a single type parameter rather than two, so the code does not compile:

Actual:

  BuiltMap<String>? get mapField;

Expected (with explicit type: object):

  BuiltMap<String, String>? get mapField;
openapi-generator version

7.21.0. I don't know if it's a regression, I just noticed it wasn't working.

OpenAPI declaration file content or url
openapi: 3.1.0

info:
  version: 0.0.0
  title: Dart bug

components:
  schemas:
    InvalidMap:
      properties:
        mapField:
          #type: object
          additionalProperties:
            type: string
Generation Details
java -jar openapi-generator-cli-7.21.0.jar generate -g dart-dio -o out -i api.yaml
Steps to reproduce

See spec and generation details above.

Related issues/PRs
Suggest a fix

The problem appears to be that variable_type.mustache uses {{baseType}} and {{isMap}} (code). baseType appears to be derived from DefaultCodegen.getPrimitiveType, which returns "map", but isMap appears to be derived from IJsonSchemaValidationProperties.setTypeProperties, which goes down the isAnyType before isMapSchema (code). Adjusting the order in setTypeProperties to be consistent with getPrimitiveType probably fixes the problem.

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