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
  • #4887
Closed
Open
Issue created Dec 29, 2019 by Administrator@rootContributor

[BUG][DART] Method listFromJson isn't defined on array of enums

Created by: selankon

Description

When I define inside an object a property that is an array of enums, the generated code call a method listFromJson that is not defined inside the enum model causing build problems.

openapi-generator version
➜ openapi-generator version
4.2.2
OpenAPI declaration file content or url
openapi: 3.0.0
info:
    title: RetroShare OpenApi wrapper
    version: 0.0.1
    description: RetroShare OpenApi wrapper generated using Doxygen documentation
    license:
        name: AGPLv3
servers:
    - url: http://127.0.0.1:9092/
    
paths:
    /jsonApiServer/version:
        post:
            summary: blahblah             
            responses:
                '200':
                    description: >
                            return: 
                    content:
                        application/json:
                            schema:
                                $ref: '#/components/schemas/FileChunksInfo'

components:      
    schemas:
        FileChunksInfo:
            type: object
            properties:
                chunks:
                    type: array
                    items:
                        $ref: '#/components/schemas/ChunkState'
        ChunkState:
            type: integer
            enum:
                
                    - 0
                    - 1
                    - 2
                    - 3
            x-enum-varnames:
                
                    - CHUNK_OUTSTANDING
                    - CHUNK_ACTIVE
                    - CHUNK_DONE
                    - CHUNK_CHECKING
Command line used for generation
➜ openapi-generator generate -i definition.yml -g dart -o openapi-dart-retroshare-api-wrapper
Steps to reproduce

Just copy the .yml definition and run the command.

After the code is generated be sure that all the dependencies are installed. I us VSCodium with Dart extension for that.

Once all installed you will see a build error on lib/model/file_chunks_info.dart.

  FileChunksInfo.fromJson(Map<String, dynamic> json) {
    if (json == null) return;
    chunks = (json['chunks'] == null) ?
      null :
      ChunkState.listFromJson(json['chunks']);
  }

Where listFromJson is not defined on ChunkState model.

Related issues/PRs

Maybe related to https://github.com/OpenAPITools/openapi-generator/issues/2567

Suggest a fix

Should the nums have the method listFromJson?

Assignee
Assign to
Time tracking