Swagger-UI применяет нежелательную кодировку в curl запроса POST - PullRequest
0 голосов
/ 07 октября 2019

Я использую OpenAPI3.0.2 в swagger, и если я хочу документировать свой вызов POST с помощью:

paths:
  /<myPath>
    post: 
      tags: 
        - <myTag>
      summary: <mySummary>
      description: <myDescription>
      operationId: <myID>
      requestBody:
        description: <myDescription>
        content:
          application/x-www-form-urlencoded:
            schema: 
              oneOf:
                - $ref: '#/components/schemas/<schema1>'
                - $ref: '#/components/schemas/<schema2>'

и схемы:

components:
  schemas:
    <schema1>:
      type: object
      properties:
        example1:
          type: array
          items:
            type: string
        pageSize:
          type: integer
          format: int64
        page:
          type: integer
          format: int64
    <schema2>:
      type: object
      properties:
        example2:
          type: array
          items:
            type: string
        pageSize:
          type: integer
          format: int64
        page:
          type: integer
          format: int64

Значение моего примера {example1: [test]} кодируется в:

curl -X POST "http://localhost:8000/<myPath>" -H "accept: */*" -H "Content-Type: application/x-www-form-urlencoded" -d "0=%7B&1=e&2=x&3=a&4=m&5=p&6=l&7=e&8=1&9=%3A&10=%5B&11=t&12=e&13=s&14=t&15=%5D&16=%7D"

, что приводит к этому на стороне сервера:

<QueryDict: {'0': ['{'], '1': ['e'], '2': ['x'], '3': ['a'], '4': ['m'], '5': ['p'], '6': ['l'], '7': ['e'], '8': ['1'], '9': ['}']}>

вместо <QueryDict: {'example1': ['test']}>

Я хочу датьинформация в разделе POST моего запроса (который работает с application/x-www-form-urlencoded). Потому что в конечном итоге я хочу прочитать это с помощью request_source.getlist на моем сервере django.

Я уже пытался добавить информацию о кодировке в application / x-www-form-urlencoded, например:

encoding:
  payload:
    contentType: application/json

но безуспешно

...