Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #3965
Closed
Open
Issue created Sep 26, 2019 by Administrator@rootContributor

[BUG][DART] oneOf dart code generation: wrong types and html-encoded code

Created by: alevinetx

Bug Report Checklist

  • [ Y] Have you provided a full/minimal spec to reproduce the issue?
  • [ Y] Have you validated the input using an OpenAPI validator (example)?
  • [ Y] What's the version of OpenAPI Generator used?
  • [Y ] Have you search for related issues/PRs?
  • [ Y] What's the actual output vs expected output?
  • [ -] [Optional] Bounty to sponsor the fix ([example]
Description

When using oneOf, with options for String or int, the generated dart code produces the class model with a few errors:

1: OneOf<string, integer> : where "string" should be "String", and "integer" should be "int". These are produced as expected (String or int) with other simple entries.

part of openapi.api;
class Pet {
  OneOf<string,integer> bodyText = null;

2: The generated code has encoded the "<>" symbols in html form (&lt;, &gt;)

    if (json['bodyText'] == null) {
      bodyText = null;
    } else {
      bodyText = OneOf&lt;string,integer&gt;.fromJson(json['bodyText']);
openapi-generator version

$ openapi-generator version 4.1.2

OpenAPI declaration file content or url

openapi: 3.0.1

    Blob:
      required:
      - name
      type: object
      properties:
        bodyText:
          oneOf:
            - type: string
            - type: integer
Command line used for generation

openapi-generator generate -i oneof.yaml -g dart -o oneof-out3a -p browserClient=false,supportDart2=true,generateAliasAsModel=true

Steps to reproduce

1: Use the default pet store model at https://editor.swagger.io/ 2: Add these 4 lines to a model's properties:

        bodyText:
          oneOf:
            - type: string
            - type: integer

3: Generate code in the manner shown above 4: Observe lib/model/.dart code

Related issues/PRs

#3884 (closed)

Suggest a fix

If I knew, I'd drop a PR :)

Assignee
Assign to
Time tracking