Skip to content

Specific Response for specific Requests #2626

Open
@zyberzebra

Description

I’d like to simulate an API that provides books. When someone requests GET /books/42, I want to return the same predefined response every time. For all other requests, I would like Prism to respond dynamically or statically based on the specified examples, as it normally does.

Is there currently a way to achieve this in Prism? If not, it would be great if such functionality could be implemented.

Let’s say I have the following endpoint:

{
  "paths": {
    "/books/{id}": {
      "get": {
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Details for a book",
            "content": {
              "application/json": {
                "example": {
                  "id": "123",
                  "title": "Default Book Title",
                  "author": "Default Author",
                  "publicationYear": 2023
                }
              }
            }
          }
        }
      }
    }
  }
}

And this is my specific example for which I would like the same response to be returned every time:

{
  "id": "42",
  "title": "The Hitchhiker's Guide to the Galaxy",
  "author": "Douglas Adams",
  "publicationYear": 1979
}

Thank you!

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions