1

I'm currently using Swagger node.js and I am able to get a response through swagger with the mock option enabled (swagger project start -m)

However, when I hit the API, the mock response is very primitive.

            "description": "Sample text",
            "disabled": true,

So for string properties, I get back "Sample Text" and for Boolean, I get back True. Is there any way to control these values? Maybe force swagger to refer to the example property?

I looked online, but couldn't find any way to achieve this.

Omri L
  • 719
  • 4
  • 12

1 Answers1

0

swagger-node-express does not use the example values specified in the API definition. To customize mock responses, you'll need to create custom mock controllers.

From the documentation:

By default, mock mode returns programmed responses, like "Sample text" for a string, a number for an integer, and so on.

But you can also create mock controllers with handler methods that return custom responses.

Place these custom "mock" controllers in the /api/mock directory.


But there are other OpenAPI/Swagger mock servers that support example values.

Community
  • 1
  • 1
Helen
  • 58,317
  • 8
  • 161
  • 218