Skip to content

[BUG][DART] Bad parameter type on enums fromJson function #5792

Closed
@selankon

Description

@selankon

Bug Report Checklist

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

For enums of type int, for example, one of the methods called fromJson has a bad type (always String) causing problems on deserialization.

openapi-generator version
➜ openapi-generator version
4.2.3
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.

If you see a build error see: #4887. Anyway, after that if you see lib/model/file_chunks_info.dart:

  static ChunkState fromJson(String value) {
    return new ChunkStateTypeTransformer().decode(value);
  }

Where String value should be int value.

Suggest a fix

Correct the template.

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