Search code examples
openapiopenapi-generator

How to get parameters in different groups in openapi-generator


I am new to openapi-generator.

Part of my yaml file is like below. in the generator (in the moustache file) I am able to get all parameters by using allParams and it will return

ChannelTimezoneNameHeader,
LanguageHeader,

goalId,
customerId

My question is how can I get first category of parameters and second category separately, not combined together?

/accounts/customer/{customerId}/goals/{goalId}/transactions:
      x-swagger-router-controller: "GoalsController"
      parameters:
        -
          $ref: "#/parameters/ChannelTimezoneNameHeader"
        -
          $ref: "#/parameters/LanguageHeader"
      get:
        tags:
          - "goals"
        summary: "get goal transactions for a customer account"
        description: ""
        operationId: "getGoalTransactions"
        security:
          -
            AuthorizationHeader: []
            XIdTokenHeader: []
        parameters:
          -
            name: "goalId"
            in: "path"
            description: "goalId"
            required: true
            type: "string"
          -
            name: "customerId"
            in: "path"
            description: "customerId"
            required: true
            type: "string"
        responses:
          200:
            description: "successful operation"
            schema:
              $ref: "#/definitions/TransactionListGoal"
          400:
            description: "Bad Request"
            schema:
              $ref: "#/definitions/ChannelApiError"
          500:
            description: "Server error"
            schema:
              $ref: "#/definitions/ChannelApiError"

Solution

  • I think you're looking for the following mustache tags:

    {{#queryParams}} ... {{/queryParams}}
    
    {{#formParams}} ... {{/formParams}}
    
    {{#headerParams}} ... {{/headerParams}}
    
    {{#pathParams}} ... {{/pathParams}}
    
    {{#bodyParams}} ... {{/bodyParams}}