Skip to content

Commit

Permalink
fix: cannot find ajv module when ibm:oas ruleset extended (#279)
Browse files Browse the repository at this point in the history
Purpose:
- Exception thrown when user creates spectral config that extends ibm:oas. Removes a rule that we want to reintroduce but allows users to extend the ibm:oas ruleset for now.

Changes:
- Remove the rule that causes this problem.
  • Loading branch information
barrett-schonefeld committed Apr 14, 2021
1 parent 2bf13e1 commit fd2cb29
Show file tree
Hide file tree
Showing 6 changed files with 0 additions and 237 deletions.
6 changes: 0 additions & 6 deletions docs/spectral-rules.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,6 @@ responses:

**Default Severity**: warn

## ibm-sdk-operations

Validates the structure of the `x-sdk-operations` object using [this JSON Schema document](/src/spectral/schemas/x-sdk-operations.json).

**Default Severity**: warn

## response-error-response-schema

`4xx` and `5xx` error responses should provide good information to help the user resolve the error. The error response validations are based on the design principles outlined in the [errors section of the IBM API Handbook](https://cloud.ibm.com/docs/api-handbook?topic=api-handbook-errors). The `response-error-response-schema` rule is more lenient than what is outlined in the handbook. Specifically, the `response-error-response-schema` rule does not require an Error Container Model and allows for a single Error Model to be provided at the top level of the error response schema or in an `error` field.
Expand Down
12 changes: 0 additions & 12 deletions src/spectral/rulesets/.defaultsForSpectral.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ extends: spectral:oas
functionsDir: './ibm-oas'
functions:
- error-response-schema
- json-schema-validation
- response-example-provided
rules:

Expand Down Expand Up @@ -121,17 +120,6 @@ rules:
then:
field: schema
function: truthy
# custom Spectral rule to ensure valid x-sdk-operations schema
ibm-sdk-operations:
message: "{{error}}"
given: $.
severity: warn
formats: ["oas3"]
resolved: true
then:
function: json-schema-validation
functionOptions:
schemaKey: 'ibm/schemas/x-sdk-operations'
# custom Spectral rule to ensure response example provided
response-example-provided:
message: "{{error}}"
Expand Down
39 changes: 0 additions & 39 deletions src/spectral/rulesets/ibm-oas/json-schema-validation.js

This file was deleted.

116 changes: 0 additions & 116 deletions src/spectral/rulesets/schemas/x-sdk-operations.json

This file was deleted.

11 changes: 0 additions & 11 deletions src/spectral/utils/spectral-validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,17 +103,6 @@ function setupStaticAssets(staticAssets, defaultSpectralRulesetURI) {

const parentDirectory = path.parse(defaultSpectralRulesetURI).dir;

// register schemas
const baseKey = 'ibm/schemas';
const schemaDirURI = path.join(parentDirectory, 'schemas');
fs.readdirSync(schemaDirURI).forEach(function(jsonSchemaFile) {
const schemaKey = path.join(baseKey, path.parse(jsonSchemaFile).name);
staticAssets[schemaKey] = fs.readFileSync(
path.join(schemaDirURI, jsonSchemaFile),
'utf8'
);
});

// register custom functions
const customFunctionsDirURI = path.join(parentDirectory, 'ibm-oas');
fs.readdirSync(customFunctionsDirURI).forEach(function(customFunctionFile) {
Expand Down
53 changes: 0 additions & 53 deletions test/spectral/tests/custom-rules/ibm-sdk-operations.test.js

This file was deleted.

0 comments on commit fd2cb29

Please sign in to comment.