Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Specific Response for specific Requests #2626

Open
zyberzebra opened this issue Nov 4, 2024 · 0 comments
Open

Specific Response for specific Requests #2626

zyberzebra opened this issue Nov 4, 2024 · 0 comments

Comments

@zyberzebra
Copy link

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!

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

No branches or pull requests

1 participant