Nathan Rutman
Nathan Rutman

Reputation: 2255

NestJS, OpenAPI, Spectral, and JSONPath for paths that include parameters

I'm using Spectral to lint my OpenAPI spec that is generated by my NestJS application.

I've implemented the URL Style Guidelines, which includes the resource-names-plural rule.

In general, plural resource names are an excellent practice. However, I have a few special endpoints that should not be plural. I have an override in the Spectral configuration that looks like this:

  - files:
      # /v1/users/me
      - "openapi.json#/paths/~1v1~1users~1me"
      # /v1/engagements/fromTemplate
      - "openapi.json#/paths/~1v1~1engagements~1from-template"
      # /v1/comments/:uuid/context
      - "openapi.json#/paths/~1v1~1comments~1{uuid}~1context"
    rules:
      resource-names-plural: "off"

While this works great for the first two examples, I cannot seem to get the third rule to match, presumably because of the {uuid} inserted into the JSONPath.

Is there a trick with JSONPath to get it to match the braces?

Thanks!

Upvotes: 0

Views: 49

Answers (0)

Related Questions