Skip to main content

The Ignore File

As you use Optic, you will probably find there are some paths you would like Optic to ignore. These can be identified individually in the undocumented endpoint review page in the UI. For ignoring routes in bulk by some characteristic, you can directly edit the project's ignore rules. Examples include ignoring all OPTIONS requests, .html, .js, .css files, or everything in your /public folder. Many of these are provided by default, and can be removed if necessary.

You can add ignore rules to your .optic/ignore file:

# Default Ignore Rules# Learn to configure your own at http://localhost:4000/reference/optic-yaml/ignoreOPTIONS (.*)HEAD (.*)GET (.*).htmGET (.*).htmlGET (.*).cssGET (.*).js...

Rules follow the following format:

METHOD(s) path
  1. The methods component can be:
    • a single method GET
    • multiple methods GET POST PUT
    • omitted -> which is interpreted as ALL
  2. The path component follows the path-to-regex format. The library has a lot of advanced features that you can use, but most use cases can probably be accomplished with the following patterns:
    • Want to ignore an absolute path? Just write it ie /users/profile
    • Want to ignore a file type? ie (.*).png (.*).js
    • Want to ignore a path and its children? /public/(.*)
    • Need something more advanced? Try creating your pattern in the path-to-regex-sandbox
  3. Scalar values in YAML cannot start with a special character ([] {} > | * & ! % # ` @ ,). If you need to start a value with *, wrap the value in double quotes.


OPTIONS (.*)               # Ignores all Options requests/public/(.*)               # Ignores all Requests to public/**GET (.*).js                # Ignores all GET requests to a resource ending in .jsGET POST PUT /resource     #Ignores all GET, POST, PUT requests to /resource