Skip to content

Fix missing path parameters when also adding headers#216

Open
matgoebl wants to merge 1 commit intoalufers:masterfrom
matgoebl:fix-missing-path-parameters-with-headers
Open

Fix missing path parameters when also adding headers#216
matgoebl wants to merge 1 commit intoalufers:masterfrom
matgoebl:fix-missing-path-parameters-with-headers

Conversation

@matgoebl
Copy link
Copy Markdown

mitmproxy2swagger adds path parameters like /{id} correctly as

      parameters:
      - name: id
        in: path
        required: true
        schema:
          type: string

When using mitmproxy2swagger --headers the headers are added, but the parameters will be missing:

      parameters:
      - name: content-type
        in: header
        required: false
        schema:
          type: string

The correct result should be

      parameters:
      - name: content-type
        in: header
        required: false
        schema:
          type: string
      - name: id
        in: path
        required: true
        schema:
          type: string

The reason for this bug is that if args.headers is used, the key parameters in swagger is already set and the later set_key_if_not_exists for params does not extend the key parameters.
One (least invasive) fix is to merge both arrays.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant