All samples

Generate an OpenAPI spec for any API

This sample contains a preset that allows you to generate an OpenAPI spec for any API. By specifying the URLs of the API for which you want to generate an OpenAPI spec, Dev Proxy will intercept all requests to that API and generate an OpenAPI spec based on the requests and responses.

Waldek Mastykarz, Garry Trinder

Generate an OpenAPI spec for any API

Summary

This sample contains a preset that allows you to generate an OpenAPI spec for any API. By specifying the URLs of the API for which you want to generate an OpenAPI spec, Dev Proxy will intercept all requests to that API and generate an OpenAPI spec based on the requests and responses.

Dev Proxy generated an OpenAPI spec for a JSON placeholder API

Compatibility

Dev Proxy v2.1.0

Contributors

Version history

VersionDateComments
1.4February 4, 2026Updated to Dev Proxy v2.1.0
1.3January 18, 2026Moved config files to .devproxy folder
1.2January 5, 2026Updated to Dev Proxy v2.0.0
1.1June 27, 2025Updated to Dev Proxy v0.29.2
1.0January 29, 2024Initial release

Minimal path to awesome

  • Get the sample:
    • Download just this sample:

      npx gitload-cli https://github.com/pnp/proxy-samples/tree/main/samples/any-generate-openapi-spec

      or

    • Download as a .ZIP file and unzip it, or

    • Clone this repository

  • Start Dev Proxy specifying the URL of the API for which you want to generate an OpenAPI spec, eg. devproxy --urls-to-watch "https://api.contoso.com/*" --record
  • Use your application to issue API requests
  • Stop Dev Proxy
  • Open the generated OpenAPI spec in the current working folder

Features

This is a generic preset for generating OpenAPI specs for any API. The preset doesn’t contain a URL and requires you to specify the URL using the --urls-to-watch, -u option.

For more information about the configuration options, see the documentation of the OpenApiSpecGenerator.

Help

We do not support samples, but this community is always willing to help, and we want to improve these samples. We use GitHub to track issues, which makes it easy for community members to volunteer their time and help resolve issues.

You can try looking at issues related to this sample to see if anybody else is having the same issues.

If you encounter any issues using this sample, create a new issue.

Finally, if you have an idea for improvement, make a suggestion.

Disclaimer

THIS CODE IS PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.