Skip to content

Multiple consecutive path parameters result in unusable code #2527

@andreaTP

Description

@andreaTP

In presence of multiple consecutive path parameters, the generator is emitting unusable code (at least in Go and Java).

And endpoint like:

  /baz/{x}/{y}:
    get:
      responses:
        "200":
          description: Something
          content:
            type: string
      parameters:
        - in: path
          name: x
          required: true
          schema:
            type: string
        - in: path
          name: y
          required: true
          schema:
            type: string

Is going to produce Builders up to the first parameter(x in the example) but will not include the second and the endpoint is unusable from Kiota-generated code (despite the code compiles).

Reproducer

  • git clone git@github.com:andreaTP/kiota.git --depth 1 --branch consecutive-path-params
  • cd kiota
  • (cd src/kiota && dotnet build)
  • ./it/generate-code.ps1 -descriptionUrl ./tests/Kiota.Builder.IntegrationTests/NoUnderscoresInModel.yaml -language java -dev
  • ./it/exec-cmd.ps1 -descriptionUrl ./tests/Kiota.Builder.IntegrationTests/NoUnderscoresInModel.yaml -language java

The test will execute, but you can notice that the generated code doesn't allows to call the baz endpoint: https://github.com/andreaTP/kiota/blob/a70d00049a3135fc7be0e0420db51854a9c2919a/it/java/no-underscores/src/test/java/BasicAPITest.java#L18-L20

Proposed solution

In presence of consecutive path parameters, we can generate "synthetic" path segments(e.g. and or then) enabling the rest of the generation to be effective.

@lucamolteni is stepping up as a volunteer to take a stab at this issue if we have an agreement on the solution.

Metadata

Metadata

Assignees

Labels

WIPgeneratorIssues or improvements relater to generation capabilities.type:bugA broken experience

Type

No type

Projects

Status

Done ✔️

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions