Copy the following command into your terminal. The only prerequisite is Node 16+.
npx counterfact@latest https://petstore3.swagger.io/api/v3/openapi.json api
- installs the
@latest
version ofcounterfact
- reads an OpenAPI 3 document (
https://petstore3.swagger.io/api/v3/openapi.json
) - generates TypeScript files in the
api
directory - starts a server which implements the API
You can use Swagger UI to try out the auto-generated API. Out of the box, it returns random responses using metadata from the OpenAPI document. Edit the files under ./api/routes
to add more realistic behavior. There's no need to restart the server.
To learn more, see the Usage Guide.