@stoplight/spectral
Advanced tools
Comparing version 0.1.2-beta.5 to 0.1.2-beta.6
@@ -13,3 +13,3 @@ "use strict"; | ||
oas2: { | ||
'operation-2xx-response': Object.assign(ruleset.rules['oas2|oas3']['operation-2xx-response'], { | ||
'operation-2xx-response': Object.assign(ruleset.rules.oas2['operation-2xx-response'], { | ||
enabled: true, | ||
@@ -16,0 +16,0 @@ }), |
@@ -13,3 +13,3 @@ "use strict"; | ||
oas2: { | ||
'operation-formData-consume-check': Object.assign(ruleset.rules['oas2|oas3']['operation-formData-consume-check'], { | ||
'operation-formData-consume-check': Object.assign(ruleset.rules.oas2['operation-formData-consume-check'], { | ||
enabled: true, | ||
@@ -16,0 +16,0 @@ }), |
@@ -13,3 +13,3 @@ "use strict"; | ||
oas2: { | ||
'operation-operationId-unique': Object.assign(ruleset.rules['oas2|oas3']['operation-operationId-unique'], { | ||
'operation-operationId-unique': Object.assign(ruleset.rules.oas2['operation-operationId-unique'], { | ||
enabled: true, | ||
@@ -16,0 +16,0 @@ }), |
@@ -13,3 +13,3 @@ "use strict"; | ||
oas2: { | ||
'operation-parameters': Object.assign(ruleset.rules['oas2|oas3']['operation-parameters'], { | ||
'operation-parameters': Object.assign(ruleset.rules.oas2['operation-parameters'], { | ||
enabled: true, | ||
@@ -16,0 +16,0 @@ }), |
@@ -13,3 +13,3 @@ "use strict"; | ||
oas2: { | ||
'path-params': Object.assign(ruleset.rules['oas2|oas3']['path-params'], { | ||
'path-params': Object.assign(ruleset.rules.oas2['path-params'], { | ||
enabled: true, | ||
@@ -16,0 +16,0 @@ }), |
@@ -1,3 +0,4 @@ | ||
import { IRuleset } from '../../types'; | ||
import { IRuleDeclaration, IRuleset } from '../../types'; | ||
export declare const operationPath = "$..paths.*[?( name() !== 'parameters' )]"; | ||
export declare const commonOasRuleset: () => IRuleset; | ||
export declare const commonOasRules: () => IRuleDeclaration; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var tslib_1 = require("tslib"); | ||
var types_1 = require("../../types"); | ||
@@ -18,408 +19,4 @@ exports.operationPath = "$..paths.*[?( name() !== 'parameters' )]"; | ||
rules: { | ||
'oas2|oas3': { | ||
'operation-parameters': { | ||
oas2: tslib_1.__assign({}, exports.commonOasRules(), { 'operation-security-defined': { | ||
enabled: true, | ||
function: 'oasOpParams', | ||
path: '$', | ||
summary: 'Operation parameters are unique and non-repeating.', | ||
type: types_1.RuleType.VALIDATION, | ||
tags: ['operation'], | ||
}, | ||
'operation-2xx-response': { | ||
enabled: true, | ||
function: 'oasOp2xxResponse', | ||
path: exports.operationPath + ".responses", | ||
summary: 'Operation must have at least one `2xx` response.', | ||
type: types_1.RuleType.STYLE, | ||
tags: ['operation'], | ||
}, | ||
'operation-operationId-unique': { | ||
enabled: true, | ||
function: 'oasOpIdUnique', | ||
path: '$', | ||
summary: 'Every operation must have a unique `operationId`.', | ||
type: types_1.RuleType.VALIDATION, | ||
tags: ['operation'], | ||
}, | ||
'operation-formData-consume-check': { | ||
enabled: true, | ||
function: 'oasOpFormDataConsumeCheck', | ||
path: exports.operationPath, | ||
summary: 'Operations with an `in: formData` parameter must include `application/x-www-form-urlencoded` or `multipart/form-data` in their `consumes` property.', | ||
type: types_1.RuleType.VALIDATION, | ||
tags: ['operation'], | ||
}, | ||
'path-params': { | ||
type: types_1.RuleType.VALIDATION, | ||
summary: 'Path parameters are correct and valid.', | ||
enabled: true, | ||
severity: types_1.RuleSeverity.ERROR, | ||
path: '$', | ||
function: 'oasPathParam', | ||
tags: ['path'], | ||
}, | ||
'contact-properties': { | ||
enabled: false, | ||
function: types_1.RuleFunction.TRUTHY, | ||
input: { | ||
properties: ['email', 'name', 'url'], | ||
}, | ||
path: '$.info.contact', | ||
summary: 'Contact object should have `name`, `url` and `email`.', | ||
type: types_1.RuleType.STYLE, | ||
tags: ['api'], | ||
}, | ||
'api-host': { | ||
enabled: true, | ||
function: types_1.RuleFunction.TRUTHY, | ||
input: { | ||
properties: ['host'], | ||
}, | ||
path: '$', | ||
summary: 'OpenAPI `host` must be present and non-empty string.', | ||
type: types_1.RuleType.STYLE, | ||
tags: ['api'], | ||
}, | ||
'api-schemes': { | ||
enabled: true, | ||
function: types_1.RuleFunction.SCHEMA, | ||
input: { | ||
schema: { | ||
items: { | ||
type: 'string', | ||
}, | ||
minItems: 1, | ||
type: 'array', | ||
}, | ||
}, | ||
path: '$.schemes', | ||
summary: 'OpenAPI host `schemes` must be present and non-empty array.', | ||
type: types_1.RuleType.STYLE, | ||
tags: ['api'], | ||
}, | ||
'example-value-or-externalValue': { | ||
enabled: false, | ||
function: types_1.RuleFunction.XOR, | ||
input: { | ||
properties: ['externalValue', 'value'], | ||
}, | ||
path: '$..example', | ||
summary: 'Example should have either a `value` or `externalValue` field.', | ||
type: types_1.RuleType.STYLE, | ||
}, | ||
'info-contact': { | ||
enabled: true, | ||
function: types_1.RuleFunction.TRUTHY, | ||
input: { | ||
properties: 'contact', | ||
}, | ||
path: '$.info', | ||
summary: 'Info object should contain `contact` object.', | ||
type: types_1.RuleType.STYLE, | ||
tags: ['api'], | ||
}, | ||
'info-description': { | ||
summary: 'OpenAPI object info `description` must be present and non-empty string.', | ||
enabled: true, | ||
function: types_1.RuleFunction.TRUTHY, | ||
input: { | ||
properties: 'description', | ||
}, | ||
path: '$.info', | ||
type: types_1.RuleType.STYLE, | ||
tags: ['api'], | ||
}, | ||
'info-license': { | ||
summary: 'OpenAPI object info `license` must be present and non-empty string.', | ||
enabled: false, | ||
function: types_1.RuleFunction.TRUTHY, | ||
input: { | ||
properties: 'license', | ||
}, | ||
path: '$.info', | ||
type: types_1.RuleType.STYLE, | ||
tags: ['api'], | ||
}, | ||
'license-apimatic-bug': { | ||
enabled: false, | ||
function: types_1.RuleFunction.NOT_CONTAIN, | ||
input: { | ||
properties: ['url'], | ||
value: 'gruntjs', | ||
}, | ||
path: '$.license', | ||
summary: 'License URL should not point at `gruntjs`.', | ||
type: types_1.RuleType.STYLE, | ||
tags: ['api'], | ||
}, | ||
'license-url': { | ||
enabled: false, | ||
function: types_1.RuleFunction.TRUTHY, | ||
input: { | ||
properties: 'url', | ||
}, | ||
path: '$.info.license', | ||
summary: 'License object should include `url`.', | ||
type: types_1.RuleType.STYLE, | ||
tags: ['api'], | ||
}, | ||
'model-description': { | ||
summary: 'Definition `description` must be present and non-empty string.', | ||
enabled: false, | ||
function: types_1.RuleFunction.TRUTHY, | ||
input: { | ||
properties: 'description', | ||
}, | ||
path: '$..definitions.*', | ||
type: types_1.RuleType.STYLE, | ||
}, | ||
'no-eval-in-descriptions': { | ||
enabled: false, | ||
function: types_1.RuleFunction.NOT_CONTAIN, | ||
input: { | ||
properties: ['description', 'title'], | ||
value: 'eval(', | ||
}, | ||
path: '$..*', | ||
summary: 'Markdown descriptions should not contain `eval(`.', | ||
type: types_1.RuleType.STYLE, | ||
}, | ||
'no-script-tags-in-markdown': { | ||
enabled: true, | ||
function: types_1.RuleFunction.NOT_CONTAIN, | ||
input: { | ||
properties: ['description'], | ||
value: '<script', | ||
}, | ||
path: '$..*', | ||
summary: 'Markdown descriptions should not contain `<script>` tags.', | ||
type: types_1.RuleType.STYLE, | ||
}, | ||
'only-local-references': { | ||
summary: 'References should start with `#/`.', | ||
enabled: false, | ||
function: types_1.RuleFunction.PATTERN, | ||
input: { | ||
value: '^#\\/', | ||
}, | ||
path: "$..['$ref']", | ||
type: types_1.RuleType.STYLE, | ||
tags: ['references'], | ||
}, | ||
'openapi-tags': { | ||
enabled: false, | ||
function: types_1.RuleFunction.TRUTHY, | ||
input: { | ||
properties: 'tags', | ||
}, | ||
path: '$', | ||
summary: 'OpenAPI object should have non-empty `tags` array.', | ||
type: types_1.RuleType.STYLE, | ||
tags: ['api'], | ||
}, | ||
'openapi-tags-alphabetical': { | ||
enabled: false, | ||
function: types_1.RuleFunction.ALPHABETICAL, | ||
input: { | ||
keyedBy: 'name', | ||
properties: 'tags', | ||
}, | ||
path: '$', | ||
summary: 'OpenAPI object should have alphabetical `tags`.', | ||
type: types_1.RuleType.STYLE, | ||
tags: ['api'], | ||
}, | ||
'operation-default-response': { | ||
summary: 'Operations must have a default response.', | ||
enabled: false, | ||
function: types_1.RuleFunction.TRUTHY, | ||
input: { | ||
properties: 'default', | ||
}, | ||
path: '$..paths.*.*.responses', | ||
type: types_1.RuleType.STYLE, | ||
tags: ['operation'], | ||
}, | ||
'operation-description': { | ||
summary: 'Operation `description` must be present and non-empty string.', | ||
enabled: true, | ||
function: types_1.RuleFunction.TRUTHY, | ||
input: { | ||
properties: 'description', | ||
}, | ||
path: exports.operationPath, | ||
type: types_1.RuleType.STYLE, | ||
tags: ['operation'], | ||
}, | ||
'operation-operationId': { | ||
enabled: true, | ||
function: types_1.RuleFunction.TRUTHY, | ||
input: { | ||
properties: 'operationId', | ||
}, | ||
path: exports.operationPath, | ||
summary: 'Operation should have an `operationId`.', | ||
type: types_1.RuleType.STYLE, | ||
tags: ['operation'], | ||
}, | ||
'operation-singular-tag': { | ||
summary: 'Operation must have one and only one tag.', | ||
enabled: false, | ||
function: types_1.RuleFunction.SCHEMA, | ||
input: { | ||
schema: { | ||
items: { | ||
type: 'string', | ||
}, | ||
maxItems: 1, | ||
minItems: 1, | ||
type: 'array', | ||
}, | ||
}, | ||
path: exports.operationPath + ".tags", | ||
type: types_1.RuleType.STYLE, | ||
tags: ['operation'], | ||
}, | ||
'operation-summary-formatted': { | ||
summary: 'Operation `summary` should start with upper case and end with a dot.', | ||
enabled: false, | ||
function: types_1.RuleFunction.PATTERN, | ||
input: { | ||
value: '^[A-Z].*\\.$', | ||
}, | ||
path: exports.operationPath + ".summary", | ||
type: types_1.RuleType.STYLE, | ||
tags: ['operation'], | ||
}, | ||
'operation-summary-or-description': { | ||
enabled: true, | ||
function: types_1.RuleFunction.OR, | ||
input: { | ||
properties: ['description', 'summary'], | ||
}, | ||
path: exports.operationPath, | ||
summary: 'Operation should have `summary` or `description`.', | ||
type: types_1.RuleType.STYLE, | ||
tags: ['operation'], | ||
}, | ||
'operation-tags': { | ||
enabled: true, | ||
function: types_1.RuleFunction.TRUTHY, | ||
input: { | ||
properties: 'tags', | ||
}, | ||
path: exports.operationPath, | ||
summary: 'Operation should have non-empty `tags` array.', | ||
type: types_1.RuleType.STYLE, | ||
tags: ['operation'], | ||
}, | ||
'parameter-description': { | ||
enabled: false, | ||
function: types_1.RuleFunction.TRUTHY, | ||
input: { | ||
properties: 'description', | ||
}, | ||
path: '$..paths.*.*.parameters', | ||
summary: 'Parameter objects should have a `description`.', | ||
type: types_1.RuleType.STYLE, | ||
tags: ['parameters'], | ||
}, | ||
'path-declarations-must-exist': { | ||
summary: 'Path declarations cannot be empty, ex.`/path/{}` is invalid.', | ||
enabled: true, | ||
function: types_1.RuleFunction.NOT_CONTAIN, | ||
input: { | ||
properties: '*', | ||
value: '{}', | ||
}, | ||
path: '$..paths', | ||
type: types_1.RuleType.STYLE, | ||
tags: ['path'], | ||
}, | ||
'path-keys-no-trailing-slash': { | ||
enabled: true, | ||
function: types_1.RuleFunction.NOT_END_WITH, | ||
input: { | ||
property: '*', | ||
value: '/', | ||
}, | ||
path: '$..paths', | ||
summary: 'Path keys should not end with a slash.', | ||
type: types_1.RuleType.STYLE, | ||
tags: ['path'], | ||
}, | ||
'path-not-include-query': { | ||
summary: 'Path keys should not include a query string.', | ||
enabled: true, | ||
function: types_1.RuleFunction.NOT_CONTAIN, | ||
input: { | ||
properties: '*', | ||
value: '\\?', | ||
}, | ||
path: '$..paths', | ||
type: types_1.RuleType.STYLE, | ||
tags: ['path'], | ||
}, | ||
'reference-components-regex': { | ||
enabled: false, | ||
function: types_1.RuleFunction.PATTERN, | ||
input: { | ||
omit: '#', | ||
split: '/', | ||
value: '^[a-zA-Z0-9\\.\\-_]+$', | ||
}, | ||
path: "$..['$ref']", | ||
summary: 'References should all match regex `^[a-zA-Z0-9\\.\\-_]+`.', | ||
type: types_1.RuleType.STYLE, | ||
tags: ['references'], | ||
}, | ||
'schema-items-is-object': { | ||
summary: 'Schema containing `items` requires the items property to be an object.', | ||
enabled: true, | ||
function: types_1.RuleFunction.SCHEMA, | ||
input: { | ||
schema: { | ||
function: 'object', | ||
}, | ||
}, | ||
path: '$..schema.items', | ||
type: types_1.RuleType.VALIDATION, | ||
}, | ||
'server-not-example.com': { | ||
enabled: false, | ||
function: types_1.RuleFunction.NOT_CONTAIN, | ||
input: { | ||
properties: ['url'], | ||
value: 'example.com', | ||
}, | ||
path: '$.servers', | ||
summary: 'Server URL should not point at `example.com`.', | ||
type: types_1.RuleType.STYLE, | ||
}, | ||
'server-trailing-slash': { | ||
enabled: true, | ||
function: types_1.RuleFunction.NOT_END_WITH, | ||
input: { | ||
property: 'url', | ||
value: '/', | ||
}, | ||
path: '$.servers', | ||
summary: 'Server URL should not have a trailing slash.', | ||
type: types_1.RuleType.STYLE, | ||
}, | ||
'tag-description': { | ||
enabled: false, | ||
function: types_1.RuleFunction.TRUTHY, | ||
input: { | ||
properties: 'description', | ||
}, | ||
path: '$.tags', | ||
summary: 'Tag object should have a `description`.', | ||
type: types_1.RuleType.STYLE, | ||
tags: ['api'], | ||
}, | ||
}, | ||
oas2: { | ||
'operation-security-defined': { | ||
enabled: true, | ||
function: 'oasOpSecurityDefined', | ||
@@ -433,6 +30,4 @@ input: { | ||
tags: ['operation'], | ||
}, | ||
}, | ||
oas3: { | ||
'operation-security-defined': { | ||
} }), | ||
oas3: tslib_1.__assign({}, exports.commonOasRules(), { 'operation-security-defined': { | ||
enabled: true, | ||
@@ -447,7 +42,409 @@ function: 'oasOpSecurityDefined', | ||
tags: ['operation'], | ||
} }), | ||
}, | ||
}; | ||
}; | ||
exports.commonOasRules = function () { return ({ | ||
'operation-parameters': { | ||
enabled: true, | ||
function: 'oasOpParams', | ||
path: '$', | ||
summary: 'Operation parameters are unique and non-repeating.', | ||
type: types_1.RuleType.VALIDATION, | ||
tags: ['operation'], | ||
}, | ||
'operation-2xx-response': { | ||
enabled: true, | ||
function: 'oasOp2xxResponse', | ||
path: exports.operationPath + ".responses", | ||
summary: 'Operation must have at least one `2xx` response.', | ||
type: types_1.RuleType.STYLE, | ||
tags: ['operation'], | ||
}, | ||
'operation-operationId-unique': { | ||
enabled: true, | ||
function: 'oasOpIdUnique', | ||
path: '$', | ||
summary: 'Every operation must have a unique `operationId`.', | ||
type: types_1.RuleType.VALIDATION, | ||
tags: ['operation'], | ||
}, | ||
'operation-formData-consume-check': { | ||
enabled: true, | ||
function: 'oasOpFormDataConsumeCheck', | ||
path: exports.operationPath, | ||
summary: 'Operations with an `in: formData` parameter must include `application/x-www-form-urlencoded` or `multipart/form-data` in their `consumes` property.', | ||
type: types_1.RuleType.VALIDATION, | ||
tags: ['operation'], | ||
}, | ||
'path-params': { | ||
type: types_1.RuleType.VALIDATION, | ||
summary: 'Path parameters are correct and valid.', | ||
enabled: true, | ||
severity: types_1.RuleSeverity.ERROR, | ||
path: '$', | ||
function: 'oasPathParam', | ||
tags: ['path'], | ||
}, | ||
'contact-properties': { | ||
enabled: false, | ||
function: types_1.RuleFunction.TRUTHY, | ||
input: { | ||
properties: ['email', 'name', 'url'], | ||
}, | ||
path: '$.info.contact', | ||
summary: 'Contact object should have `name`, `url` and `email`.', | ||
type: types_1.RuleType.STYLE, | ||
tags: ['api'], | ||
}, | ||
'api-host': { | ||
enabled: true, | ||
function: types_1.RuleFunction.TRUTHY, | ||
input: { | ||
properties: ['host'], | ||
}, | ||
path: '$', | ||
summary: 'OpenAPI `host` must be present and non-empty string.', | ||
type: types_1.RuleType.STYLE, | ||
tags: ['api'], | ||
}, | ||
'api-schemes': { | ||
enabled: true, | ||
function: types_1.RuleFunction.SCHEMA, | ||
input: { | ||
schema: { | ||
items: { | ||
type: 'string', | ||
}, | ||
minItems: 1, | ||
type: 'array', | ||
}, | ||
}, | ||
}; | ||
}; | ||
path: '$.schemes', | ||
summary: 'OpenAPI host `schemes` must be present and non-empty array.', | ||
type: types_1.RuleType.STYLE, | ||
tags: ['api'], | ||
}, | ||
'example-value-or-externalValue': { | ||
enabled: false, | ||
function: types_1.RuleFunction.XOR, | ||
input: { | ||
properties: ['externalValue', 'value'], | ||
}, | ||
path: '$..example', | ||
summary: 'Example should have either a `value` or `externalValue` field.', | ||
type: types_1.RuleType.STYLE, | ||
}, | ||
'info-contact': { | ||
enabled: true, | ||
function: types_1.RuleFunction.TRUTHY, | ||
input: { | ||
properties: 'contact', | ||
}, | ||
path: '$.info', | ||
summary: 'Info object should contain `contact` object.', | ||
type: types_1.RuleType.STYLE, | ||
tags: ['api'], | ||
}, | ||
'info-description': { | ||
summary: 'OpenAPI object info `description` must be present and non-empty string.', | ||
enabled: true, | ||
function: types_1.RuleFunction.TRUTHY, | ||
input: { | ||
properties: 'description', | ||
}, | ||
path: '$.info', | ||
type: types_1.RuleType.STYLE, | ||
tags: ['api'], | ||
}, | ||
'info-license': { | ||
summary: 'OpenAPI object info `license` must be present and non-empty string.', | ||
enabled: false, | ||
function: types_1.RuleFunction.TRUTHY, | ||
input: { | ||
properties: 'license', | ||
}, | ||
path: '$.info', | ||
type: types_1.RuleType.STYLE, | ||
tags: ['api'], | ||
}, | ||
'license-apimatic-bug': { | ||
enabled: false, | ||
function: types_1.RuleFunction.NOT_CONTAIN, | ||
input: { | ||
properties: ['url'], | ||
value: 'gruntjs', | ||
}, | ||
path: '$.license', | ||
summary: 'License URL should not point at `gruntjs`.', | ||
type: types_1.RuleType.STYLE, | ||
tags: ['api'], | ||
}, | ||
'license-url': { | ||
enabled: false, | ||
function: types_1.RuleFunction.TRUTHY, | ||
input: { | ||
properties: 'url', | ||
}, | ||
path: '$.info.license', | ||
summary: 'License object should include `url`.', | ||
type: types_1.RuleType.STYLE, | ||
tags: ['api'], | ||
}, | ||
'model-description': { | ||
summary: 'Definition `description` must be present and non-empty string.', | ||
enabled: false, | ||
function: types_1.RuleFunction.TRUTHY, | ||
input: { | ||
properties: 'description', | ||
}, | ||
path: '$..definitions.*', | ||
type: types_1.RuleType.STYLE, | ||
}, | ||
'no-eval-in-descriptions': { | ||
enabled: false, | ||
function: types_1.RuleFunction.NOT_CONTAIN, | ||
input: { | ||
properties: ['description', 'title'], | ||
value: 'eval(', | ||
}, | ||
path: '$..*', | ||
summary: 'Markdown descriptions should not contain `eval(`.', | ||
type: types_1.RuleType.STYLE, | ||
}, | ||
'no-script-tags-in-markdown': { | ||
enabled: true, | ||
function: types_1.RuleFunction.NOT_CONTAIN, | ||
input: { | ||
properties: ['description'], | ||
value: '<script', | ||
}, | ||
path: '$..*', | ||
summary: 'Markdown descriptions should not contain `<script>` tags.', | ||
type: types_1.RuleType.STYLE, | ||
}, | ||
'only-local-references': { | ||
summary: 'References should start with `#/`.', | ||
enabled: false, | ||
function: types_1.RuleFunction.PATTERN, | ||
input: { | ||
value: '^#\\/', | ||
}, | ||
path: "$..['$ref']", | ||
type: types_1.RuleType.STYLE, | ||
tags: ['references'], | ||
}, | ||
'openapi-tags': { | ||
enabled: false, | ||
function: types_1.RuleFunction.TRUTHY, | ||
input: { | ||
properties: 'tags', | ||
}, | ||
path: '$', | ||
summary: 'OpenAPI object should have non-empty `tags` array.', | ||
type: types_1.RuleType.STYLE, | ||
tags: ['api'], | ||
}, | ||
'openapi-tags-alphabetical': { | ||
enabled: false, | ||
function: types_1.RuleFunction.ALPHABETICAL, | ||
input: { | ||
keyedBy: 'name', | ||
properties: 'tags', | ||
}, | ||
path: '$', | ||
summary: 'OpenAPI object should have alphabetical `tags`.', | ||
type: types_1.RuleType.STYLE, | ||
tags: ['api'], | ||
}, | ||
'operation-default-response': { | ||
summary: 'Operations must have a default response.', | ||
enabled: false, | ||
function: types_1.RuleFunction.TRUTHY, | ||
input: { | ||
properties: 'default', | ||
}, | ||
path: '$..paths.*.*.responses', | ||
type: types_1.RuleType.STYLE, | ||
tags: ['operation'], | ||
}, | ||
'operation-description': { | ||
summary: 'Operation `description` must be present and non-empty string.', | ||
enabled: true, | ||
function: types_1.RuleFunction.TRUTHY, | ||
input: { | ||
properties: 'description', | ||
}, | ||
path: exports.operationPath, | ||
type: types_1.RuleType.STYLE, | ||
tags: ['operation'], | ||
}, | ||
'operation-operationId': { | ||
enabled: true, | ||
function: types_1.RuleFunction.TRUTHY, | ||
input: { | ||
properties: 'operationId', | ||
}, | ||
path: exports.operationPath, | ||
summary: 'Operation should have an `operationId`.', | ||
type: types_1.RuleType.STYLE, | ||
tags: ['operation'], | ||
}, | ||
'operation-singular-tag': { | ||
summary: 'Operation must have one and only one tag.', | ||
enabled: false, | ||
function: types_1.RuleFunction.SCHEMA, | ||
input: { | ||
schema: { | ||
items: { | ||
type: 'string', | ||
}, | ||
maxItems: 1, | ||
minItems: 1, | ||
type: 'array', | ||
}, | ||
}, | ||
path: exports.operationPath + ".tags", | ||
type: types_1.RuleType.STYLE, | ||
tags: ['operation'], | ||
}, | ||
'operation-summary-formatted': { | ||
summary: 'Operation `summary` should start with upper case and end with a dot.', | ||
enabled: false, | ||
function: types_1.RuleFunction.PATTERN, | ||
input: { | ||
value: '^[A-Z].*\\.$', | ||
}, | ||
path: exports.operationPath + ".summary", | ||
type: types_1.RuleType.STYLE, | ||
tags: ['operation'], | ||
}, | ||
'operation-summary-or-description': { | ||
enabled: true, | ||
function: types_1.RuleFunction.OR, | ||
input: { | ||
properties: ['description', 'summary'], | ||
}, | ||
path: exports.operationPath, | ||
summary: 'Operation should have `summary` or `description`.', | ||
type: types_1.RuleType.STYLE, | ||
tags: ['operation'], | ||
}, | ||
'operation-tags': { | ||
enabled: true, | ||
function: types_1.RuleFunction.TRUTHY, | ||
input: { | ||
properties: 'tags', | ||
}, | ||
path: exports.operationPath, | ||
summary: 'Operation should have non-empty `tags` array.', | ||
type: types_1.RuleType.STYLE, | ||
tags: ['operation'], | ||
}, | ||
'parameter-description': { | ||
enabled: false, | ||
function: types_1.RuleFunction.TRUTHY, | ||
input: { | ||
properties: 'description', | ||
}, | ||
path: '$..paths.*.*.parameters', | ||
summary: 'Parameter objects should have a `description`.', | ||
type: types_1.RuleType.STYLE, | ||
tags: ['parameters'], | ||
}, | ||
'path-declarations-must-exist': { | ||
summary: 'Path declarations cannot be empty, ex.`/path/{}` is invalid.', | ||
enabled: true, | ||
function: types_1.RuleFunction.NOT_CONTAIN, | ||
input: { | ||
properties: '*', | ||
value: '{}', | ||
}, | ||
path: '$..paths', | ||
type: types_1.RuleType.STYLE, | ||
tags: ['path'], | ||
}, | ||
'path-keys-no-trailing-slash': { | ||
enabled: true, | ||
function: types_1.RuleFunction.NOT_END_WITH, | ||
input: { | ||
property: '*', | ||
value: '/', | ||
}, | ||
path: '$..paths', | ||
summary: 'Path keys should not end with a slash.', | ||
type: types_1.RuleType.STYLE, | ||
tags: ['path'], | ||
}, | ||
'path-not-include-query': { | ||
summary: 'Path keys should not include a query string.', | ||
enabled: true, | ||
function: types_1.RuleFunction.NOT_CONTAIN, | ||
input: { | ||
properties: '*', | ||
value: '\\?', | ||
}, | ||
path: '$..paths', | ||
type: types_1.RuleType.STYLE, | ||
tags: ['path'], | ||
}, | ||
'reference-components-regex': { | ||
enabled: false, | ||
function: types_1.RuleFunction.PATTERN, | ||
input: { | ||
omit: '#', | ||
split: '/', | ||
value: '^[a-zA-Z0-9\\.\\-_]+$', | ||
}, | ||
path: "$..['$ref']", | ||
summary: 'References should all match regex `^[a-zA-Z0-9\\.\\-_]+`.', | ||
type: types_1.RuleType.STYLE, | ||
tags: ['references'], | ||
}, | ||
'schema-items-is-object': { | ||
summary: 'Schema containing `items` requires the items property to be an object.', | ||
enabled: true, | ||
function: types_1.RuleFunction.SCHEMA, | ||
input: { | ||
schema: { | ||
function: 'object', | ||
}, | ||
}, | ||
path: '$..schema.items', | ||
type: types_1.RuleType.VALIDATION, | ||
}, | ||
'server-not-example.com': { | ||
enabled: false, | ||
function: types_1.RuleFunction.NOT_CONTAIN, | ||
input: { | ||
properties: ['url'], | ||
value: 'example.com', | ||
}, | ||
path: '$.servers', | ||
summary: 'Server URL should not point at `example.com`.', | ||
type: types_1.RuleType.STYLE, | ||
}, | ||
'server-trailing-slash': { | ||
enabled: true, | ||
function: types_1.RuleFunction.NOT_END_WITH, | ||
input: { | ||
property: 'url', | ||
value: '/', | ||
}, | ||
path: '$.servers', | ||
summary: 'Server URL should not have a trailing slash.', | ||
type: types_1.RuleType.STYLE, | ||
}, | ||
'tag-description': { | ||
enabled: false, | ||
function: types_1.RuleFunction.TRUTHY, | ||
input: { | ||
properties: 'description', | ||
}, | ||
path: '$.tags', | ||
summary: 'Tag object should have a `description`.', | ||
type: types_1.RuleType.STYLE, | ||
tags: ['api'], | ||
}, | ||
}); }; | ||
//# sourceMappingURL=index.js.map |
@@ -6,3 +6,3 @@ /// <reference types="node" /> | ||
import { Rule } from './rule'; | ||
export declare type TargetSpec = 'oas2' | 'oas3' | 'oas2|oas3' | '*'; | ||
export declare type TargetSpec = 'oas2' | 'oas3' | string; | ||
export declare type RawResult = ErrorObject | AssertionError; | ||
@@ -56,3 +56,3 @@ export declare type Path = Array<string | number>; | ||
* index is a simplified regex of the format(s) the rules apply to (ie, | ||
* 'oas2', 'oas2|oas3', '*') | ||
* 'oas2', 'oas3') | ||
*/ | ||
@@ -59,0 +59,0 @@ [index: string]: IRuleDeclaration; |
{ | ||
"name": "@stoplight/spectral", | ||
"version": "0.1.2-beta.5", | ||
"version": "0.1.2-beta.6", | ||
"description": "An object linting framework", | ||
@@ -5,0 +5,0 @@ "author": "Stoplight, Inc. (support@stoplight.io)", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
267681
6073