ErikWittern / openapi-snippet

Generates code snippets for given Swagger / Open API documents
MIT License
115 stars 66 forks source link

application/x-www-form-urlencoded media type examples not supported #66

Closed d-silva closed 3 years ago

d-silva commented 3 years ago

Hi @ErikWittern

First of all thanks for your work.

The OpenAPI to HAR lib is not fully supporting the application/x-www-form-urlencoded media type, payload examples are being ignored.

Example

This OpenAPI path:

# ...

paths:
  "/auth/token":
    servers:
      - url: https://auth.com
        description: Auth API
    post:
      requestBody:
        required: true
        content:
          application/x-www-form-urlencoded:
            schema:
              type: object
              required:
                - id
                - secret
              properties:
                id:
                  type: string
                  example: "id"
                secret:
                  type: string
                  example: "secret"

# ...

With shell_curl lang target will output only this:

curl --request POST \
    --url https://auth.com/auth/token \
    --header 'content-type: application/x-www-form-urlencoded

I've opened a PR with my suggestion #67 (Full disclosure, I have no relevant experience developing in JavaScript. This being said, if there's an easier/better way to do it let me know)

ErikWittern commented 3 years ago

@d-silva Thanks for filing this, providing a PR, and iterating on it. The just released version 0.11.0 now includes support for the application/x-www-form-urlencode media type.

d-silva commented 3 years ago

Thank you for all your help along the process 🍻