prism icon indicating copy to clipboard operation
prism copied to clipboard

Support "encoding" keyword - Requests to Mocked API on postman results 422 error

Open tiagomarto opened this issue 4 years ago • 6 comments

Describe Issue

I'm mocking a API that receives as input a x-www-form-urlencoded containing a key called request and a json as value (yaml below for reference).

openapi: "3.0.0"
info:
  description: "Example Documentation"
  version: "1.0.0"
  title: "Example"
servers:
  - url: http://myurl.com
tags:
  - name: "example"
    description: "example"
paths:
  /json:
    post:
      tags:
        - example
      summary: "this is my example"
      description: ""
      requestBody:
        required: true
        content:
          application/x-www-form-urlencoded:
            schema:
              type: object
              properties:
                request:
                  $ref: "#/components/schemas/request"
            encoding:
              request:
                contentType: application/json

      responses:
        "200":
          description: "OK"
          content:
            application/json:
              schema:
                type: object
                properties:
                  responseCode:
                    type: integer
                    example: 0
                  description:
                    type: string
                    example: "OK"
                  url:
                    type: string
                    example: "http://myurl.com/response"

components:
  schemas:
    request:
      type: object
      required:
        - amount
        - merchant_id
      properties:
        amount:
          type: integer
          example: 100
        merchant_id:
          type: string
          example: "merchant_id"

I'm running Prism in a docker container and running the yaml file to generate the mock.

The docker command i'm using is as below:

docker run --init --rm -v ${PWD}:/tmp -p 4010:4010 stoplight/prism mock -h 0.0.0.0 "/tmp/example.yaml"

Yet, when I make a request in postman at /json it returns me 422 error, as seen in the picture:

Postman Output

Expected Behavior

I Expect Prism to give me the 200 code output with the response examples

Is this a problem from my setup or Prism can't handle this input format?

tiagomarto avatar Jan 06 '21 21:01 tiagomarto

Correct, we do not support the encoding keyword just yet, that's a power user thing you don't often see in the wild.

Fancy rolling your sleeves up and giving us a hand? It looks like there's two of you interested, but we've got more features on our roadmap than we have developers to write them.

philsturgeon avatar Jan 21 '21 16:01 philsturgeon

Hey team, do you have plans for adding support for application/x-www-form-urlencoded request bodies anytime soon?

gabriel-bazan-pp avatar Jun 17 '21 22:06 gabriel-bazan-pp

Removing points to re-groom and discuss with team.

ryotrellim avatar Oct 04 '21 20:10 ryotrellim

Hey team! Please add your planning poker estimate with ZenHub @Amjcraft @lukasz-kuzynski-11sigma @radzserg @rainum

chohmann avatar Oct 04 '21 21:10 chohmann

  • OASv3.1 - https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#encoding-object
  • OASv3.0 - https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#encoding-object
  • OASv2.0 - not a thing.

philsturgeon avatar Oct 07 '21 06:10 philsturgeon

Hey team! Please add your planning poker estimate with ZenHub @Amjcraft @daniel-white @EdVinyard @jasonmgillhub @rainum

chohmann avatar Jan 31 '22 21:01 chohmann