Skip to content

Object and primitive as parameter cause type mismatch #4

@timo-a

Description

@timo-a

When I generate the following schema which is valid according to https://apitools.dev/swagger-parser/online/:

openapi: 3.0.1
info:
  title: heterogenous params bug report
  version: 0.0.0
paths:
  /debug/stepPolarSession{foo}/{ba}:
    post:
      tags:
      - error-repro
      operationId: reproduceBbug
      parameters:
      - name: foo
        in: path
        required: true
        schema:
          $ref: '#/components/schemas/Cat'
      - name: ba
        in: path
        required: true
        schema:
          type: integer
          format: int32
      responses:
        "200":
          description: OK
          content:
            '*/*':
              schema:
                $ref: '#/components/schemas/Cat'
components:
  schemas:
    Cat:
      required:
      - theta
      type: object
      properties:
        theta:
          type: number
          format: double

I get an error when makeing it:

Detected problems in 1 module.
-- TYPE MISMATCH ---------------------- generated/src/Api/Request/ErrorRepro.elm

The 2nd element of this list does not match all the previous elements:

34|         [ ( "foo",  foo_path ), ( "ba", String.fromInt ba_path ) ]
                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The 2nd element is a tuple of type:

    ( String, String )

But all the previous elements in the list are:

    ( String, Api.Data.Cat )

Hint: Everything in a list must be the same type of value. This way, we never
run into unexpected values partway through a List.map, List.foldl, etc. Read
<https://elm-lang.org/0.19.1/custom-types> to learn how to “mix” types.

I use java -jar openapi-generator-cli-5.0.0-20201029.041527-838.jar generate -g elm -i spec.yaml -o generated for generation and elm make src/Main.elm for building.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions