OpenAPI.NET icon indicating copy to clipboard operation
OpenAPI.NET copied to clipboard

Azure API Management ignores formData input parameters

Open adrianwright109 opened this issue 5 years ago • 1 comments

I have an API built using ServiceStack which implements the Swagger UI and OpenAPI 2.0 specification.

I have several POST methods that use formData inputs and these show in the Swagger UI as individual input textboxes as shown below: NIhvT

The OpenApi output that Swagger generates looks like this for the input parameters:

  '/api/{Version}/apimethod':
    post:
      tags:
        - API
      summary: Get a values from an API.
      description: Notes here
      operationId: UniqueOperationId
      consumes:
        - application/x-www-form-urlencoded
      produces:
        - application/json
      parameters:
        - name: Field1
          in: formData
          description: Field1
          type: number
          format: double
          required: false
          x-nullable: false
        - name: Field2
          in: formData
          description: Field2
          type: integer
          format: int32
          required: false
          x-nullable: false
        - name: Field3
          in: formData
          description: Field3
          type: integer
          format: int32
          required: false
          x-nullable: false
        - name: Field4
          in: formData
          description: Field4
          type: integer
          format: int32
          required: false
          x-nullable: false
        - name: Field5
          in: formData
          description: Field5
          type: number
          format: double
          required: false
          x-nullable: false
        - name: Field6
          in: formData
          description: Field6
          type: integer
          format: int32
          required: false
          x-nullable: false
        - name: Field7
          in: formData
          description: Field7
          type: integer
          format: int32
          required: false
          x-nullable: false
        - name: Field8
          in: formData
          description: Field8
          type: integer
          format: int32
          required: true
          x-nullable: false
        - name: Version
          in: path
          description: Version of the API to call
          type: integer
          format: int32
          required: true
          x-nullable: false
      responses:
        '200':
          description: Success
          schema:
            $ref: '#/definitions/GetApiMethodResponse'
        '400':
          description: Your request was not understood
          schema:
            $ref: '#/definitions/GetApiMethodResponse'
        '500':
          description: 'Oops, something broke'
          schema:
            $ref: '#/definitions/GetApiMethodResponse'
      deprecated: false
    parameters:
      - $ref: '#/parameters/Accept'

If I import the OpenAPI specification into the Azure API Management service to create an new API facade it ignores the formData inputs.

I was expecting that it would list all of the individual inputs and their descriptions in the Azure API Management portal just like the Swagger UI does.

Am I doing something wrong or does the Azure API Management service not list individual formData input parameters the same as the Swagger UI?

My API methods do have alot of parameters and its not very helpful to the end users of the Azure API Management portal to have to fill in a JSON payload which has no descriptions as to what each property on the JSON payload does.

adrianwright109 avatar Nov 17 '20 12:11 adrianwright109

API management will show these as a request body because that is the shape of the HTTP request. Treating FormData parts as parameters was something OpenAPI V2 did, but OpenAPI v3 doesn't because it isn't an accurate modelling of the HTTP request.

In OpenAPI V3, a JSON Schema can be used to describe the properties of a form data payload. Tooling, such as APIM, can use this information to present a UI for filling formData parameters.

I am a bit confused as to why your users are having to fill in a JSON payload when your parameters are part of a FormData payload. That doesn't seem correct.

darrelmiller avatar Dec 13 '20 18:12 darrelmiller