swagger-api / swagger-api/swagger-codegen

[Kotlin-Client] Malfunctioning integer parameter with format: int64

Open
#9,017 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

Description

When generating from a swagger.json that has a get method with an required int64 path parameter, the resulting type is kotlin.Int in this case, but should be kotlin.Long. In arrays the int64 type does work though.

The problem itself seems to be related to deserialization and model generation of the swagger.json, because the Parameter object's schema is not an IntegerSchema, but instead an object of the plain Schema class. This leads to wrong decisions when checking with ... instanceof IntegerSchema in the code generator.

Honestly, I have no idea where to open this issue, but the bug appeared with the latest version 3 and 2.4 of the code generator.

Swagger-codegen version

Version 3 (latest git) and 2.4.

Swagger declaration file content or url

https://esi.evetech.net/latest/swagger.json?datasource=tranquility

Command line used for generation

java -jar swagger-codegen-cli-3.0.4-SNAPSHOT.jar generate -l kotlin-client --template-engine handlebars -i https://esi.evetech.net/latest/swagger.json?datasource=tranquility

on Arch Linux with Java:

$ java -version
openjdk version "1.8.0_192"
OpenJDK Runtime Environment (build 1.8.0_192-b26)
OpenJDK 64-Bit Server VM (build 25.192-b26, mixed mode)
Steps to reproduce

Generate with the command and versions above and look into the MarketApi#getMarketsStructuresStructureId method and look at the parameter structureId. It should be kotlin.Long instead of kotlin.Int, as described in the swagger.json:

...
    "/markets/structures/{structure_id}/": {
      "get": {
        "description": "Return all orders in a structure\n\n---\nAlternate route: `/dev/markets/structures/{structure_id}/`\n\nAlternate route: `/legacy/markets/structures/{structure_id}/`\n\nAlternate route: `/v1/markets/structures/{structure_id}/`\n\n---\nThis route is cached for up to 300 seconds",
        "operationId": "get_markets_structures_structure_id",
        "parameters": [
          ...
          {
            "description": "Return orders in this structure",
            "format": "int64",
            "in": "path",
            "name": "structure_id",
            "required": true,
            "type": "integer"
          },
...
Related issues/PRs

Haven't seen any

Suggest a fix/enhancement

As this seems to be a problem with the deserialization and therefor may be related to the swagger-core, I have briefly debugged through there, but found no obvious issue with the code.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue with the linked swagger.json and the documented swagger-codegen-cli command using the kotlin-client generator and Handlebars. Inspect generation of MarketApi#getMarketsStructuresStructureId, especially the structureId parameter, and trace how its int64 schema is represented. Done means the generated parameter is kotlin.Long rather than kotlin.Int, with regression coverage if the relevant generator test location is identified.

Written by the indexing model from the issue text.

Assessment

Tech stack
handlebars, java, kotlin
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.