extends: spectral:oas rules: tesla-operation-ids-present: description: All operations must have operationId defined message: "Operation at {{path}} is missing operationId" severity: error given: "$.paths.*[get,post,put,patch,delete]" then: field: operationId function: truthy tesla-operation-id-pascal-case: description: Operation IDs should use PascalCase message: "Operation ID '{{value}}' should use PascalCase" severity: warn given: "$.paths.*[get,post,put,patch,delete].operationId" then: function: pattern functionOptions: match: "^[A-Z][A-Za-z0-9]+$" tesla-summaries-start-with-provider: description: Tesla API summaries should start with the provider name "Tesla" message: "Summary '{{value}}' should start with 'Tesla '" severity: info given: "$.paths.*[get,post,put,patch,delete].summary" then: function: pattern functionOptions: match: "^Tesla " tesla-tags-required: description: Each operation should have at least one tag message: "Operation at {{path}} should have at least one tag" severity: warn given: "$.paths.*[get,post,put,patch,delete]" then: field: tags function: truthy tesla-bearer-auth: description: Tesla API uses OAuth2 bearer token authentication message: "Security should use bearer token" severity: warn given: "$.components.securitySchemes.*" then: function: schema functionOptions: schema: type: object anyOf: - properties: type: const: http scheme: const: bearer - properties: type: const: oauth2 tesla-vehicle-id-path-param: description: Vehicle endpoints should use vehicle_id path parameter message: "Vehicle path should use {vehicle_id} parameter" severity: info given: "$.paths./api/1/vehicles/*" then: function: truthy tesla-response-200: description: Operations should define a 200 response message: "Operation should define a 200 OK response" severity: warn given: "$.paths.*[get,post]" then: function: schema functionOptions: schema: type: object properties: responses: type: object required: ["200"] tesla-parameter-descriptions: description: Path parameters should have descriptions message: "Path parameter is missing a description" severity: warn given: "$.paths..parameters[?(@.in == 'path')]" then: field: description function: truthy