1
votes

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: enter image description here

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.

1

1 Answers

1
votes

According to your description, I assume your purpose is importing OpenAPI specification into the Azure API Management service and keeping the parameter description in the apim page.

I find that 'post' request can add query parameter but 'get' request can't. After adding some parameters, I get following view. I added 3 parameters, I added description of each parameter but none of them showed in this page. enter image description here

After that, I exported the api and I got a file named hello.openapi.yaml, here is the detail. I can modify the parameters in this file and then import it in an Api instance.

openapi: 3.0.1
info:
  title: hello
  description: ''
  version: '1.0'
servers:
  - url: http://tinyapim.azure-api.net/index
paths:
  /hello:
    get:
      summary: hello
      operationId: hello
      responses:
        '200':
          description: 
  /getJsonObject:
    get:
      summary: getJsonObject
      operationId: getjsonobject
      responses:
        '200':
          description: 
  /sendpost:
    post:
      summary: sendPost
      operationId: sendpost
      parameters:
        - name: userName
          in: query
          description: description1
          schema:
            enum:
              - hello
            type: string
        - name: userId
          in: query
          description: required param
          required: true
          schema:
            type: ''
        - name: age
          in: query
          schema:
            type: int
      responses:
        '200':
          description: 
components:
  securitySchemes:
    apiKeyHeader:
      type: apiKey
      name: Ocp-Apim-Subscription-Key
      in: header
    apiKeyQuery:
      type: apiKey
      name: subscription-key
      in: query
security:
  - apiKeyHeader: [ ]
  - apiKeyQuery: [ ]

enter image description here

I think these are all Apim can do on your case. Wish it would help.