Skip to content

Multi-parameter URL with dash in between parameters not recognizing each parameter #115

@blakewatkins

Description

@blakewatkins

While trying to use the openapi gradle task, I am running across an issue with the path parameters. My URL has two parameters separated by a dash and they are not being recognized as two separate parameters, but instead as one which includes the inner brackets and the dash (Ex. .../{param1}-{param2}/... gives me one single parameter "param1}-{param2").

My test is as follows:

@Test
  public void getPartiesByAbo_200success() throws Exception {
    this.mockMvc
            .perform(get("/v4/parties/{salesPlanAff}-{aboNum}/party", 1, 1L))
            .andExpect(status().isOk())
            .andDo(
                    document(
                            "getPartyByABO",
                            resource(
                                    ResourceSnippetParameters.builder()
                                            .description("Get all parties associated with a given aff-abo combination")
                                            .summary(
                                                    "This operation will return a list of partyIds and globalPartyIds associated with a given aff-abo.")
                                            .pathParameters(
                                                    parameterWithName("salesPlanAff")
                                                            .description(
                                                                    "The Sales Plan Affiliate portion of the aff-abo being searched for"),
                                                    parameterWithName("aboNum")
                                                            .description(
                                                                    "The ABO portion of the aff-abo being searched for"))
                                            .responseFields(
                                                    fieldWithPath("affAbo")
                                                            .description("The aff-abo whose parties are being searched for"),
                                                    fieldWithPath("partyIds")
                                                            .description(
                                                                    "The list of partyIds associated with the given aff-abo"),
                                                    fieldWithPath("globalPartyIds")
                                                            .description(
                                                                    "The list of globalPartyIds associated with the given aff-abo"))
                                            .build())));
  }

Asciidoctor is generating the snippet correctly with the individual parameters, but the openapi.yaml document that is generated when the openapi task is run gives the combined parameter.

Asciidoctor snippet:

{
  "operationId" : "getPartyByABO",
  "summary" : "This operation will return a list of partyIds and globalPartyIds associated with a given aff-abo.",
  "description" : "Get all parties associated with a given aff-abo combination",
  "privateResource" : false,
  "deprecated" : false,
  "request" : {
    "path" : "/v4/parties/{salesPlanAff}-{aboNum}/party",
    "method" : "GET",
    "contentType" : null,
    "headers" : [ ],
    "pathParameters" : [ {
      "name" : "salesPlanAff",
      "attributes" : { },
      "description" : "The Sales Plan Affiliate portion of the aff-abo being searched for",
      "ignored" : false,
      "type" : "STRING",
      "optional" : false
    }, {
      "name" : "aboNum",
      "attributes" : { },
      "description" : "The ABO portion of the aff-abo being searched for",
      "ignored" : false,
      "type" : "STRING",
      "optional" : false
    } ],
    "requestParameters" : [ ],
    "requestFields" : [ ],
    "example" : null,
    "securityRequirements" : null
  },
  "response" : {
    "status" : 200,
    "contentType" : "application/json",
    "headers" : [ ],
    "responseFields" : [ {
      "attributes" : { },
      "description" : "The aff-abo whose parties are being searched for",
      "ignored" : false,
      "path" : "affAbo",
      "type" : "STRING",
      "optional" : false
    }, {
      "attributes" : { },
      "description" : "The list of partyIds associated with the given aff-abo",
      "ignored" : false,
      "path" : "partyIds",
      "type" : "ARRAY",
      "optional" : false
    }, {
      "attributes" : { },
      "description" : "The list of globalPartyIds associated with the given aff-abo",
      "ignored" : false,
      "path" : "globalPartyIds",
      "type" : "ARRAY",
      "optional" : false
    } ],
    "example" : "{\r\n  \"affAbo\" : \"1-1\",\r\n  \"partyIds\" : [ 1, 2 ],\r\n  \"globalPartyIds\" : [ 1, 2 ]\r\n}"
  },
  "tags" : [ "v4" ]
}

openapi.yaml:

/v4/parties/{salesPlanAff}-{aboNum}/party:
    get:
      tags:
      - v4
      summary: This operation will return a list of partyIds and globalPartyIds associated
        with a given aff-abo.
      description: Get all parties associated with a given aff-abo combination
      operationId: getPartyByABO
      produces:
      - application/json
      parameters:
      - name: salesPlanAff}-{aboNum
        in: path
        description: ""
        required: true
        type: string
      responses:
        200:
          description: ""
          examples:
            application/json: "{\r\n  \"affAbo\" : \"1-1\",\r\n  \"partyIds\" : [\
              \ 1, 2 ],\r\n  \"globalPartyIds\" : [ 1, 2 ]\r\n}"
          schema:
            $ref: '#/definitions/v4_parties_salesPlanAff-aboNum_party809631298'

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions