diff --git a/openapi/petstore.yaml b/openapi/petstore.yaml index 5cf68e7b..0e47b548 100644 --- a/openapi/petstore.yaml +++ b/openapi/petstore.yaml @@ -1,4 +1,5 @@ openapi: 3.0.3 +security: [] servers: - url: '//petstore.swagger.io/v2' info: diff --git a/openapi/reference.page.yaml b/openapi/reference.page.yaml index 451207b2..7620496a 100644 --- a/openapi/reference.page.yaml +++ b/openapi/reference.page.yaml @@ -6,3 +6,4 @@ settings: - lang: curl - lang: JavaScript - lang: Node.js + diff --git a/plugins/plugin.js b/plugins/plugin.js new file mode 100644 index 00000000..5bf2a290 --- /dev/null +++ b/plugins/plugin.js @@ -0,0 +1,14 @@ +const OperationIdNotTest = require('./rules/operation-id-not-test'); +const id = 'plugin'; + +/** @type {import('@redocly/cli').DecoratorsConfig} */ +const rules = { + oas3: { + 'operation-id-not-test': OperationIdNotTest, + }, +}; + +module.exports = { + id, + rules, +}; \ No newline at end of file diff --git a/plugins/rules/operation-id-not-test.js b/plugins/rules/operation-id-not-test.js new file mode 100644 index 00000000..195ab001 --- /dev/null +++ b/plugins/rules/operation-id-not-test.js @@ -0,0 +1,14 @@ +module.exports = OperationIdNotTest; + +function OperationIdNotTest() { + return { + Operation(operation, ctx) { + if (operation.operationId === 'test') { + ctx.report({ + message: `operationId must be not "test"`, + location: ctx.location.child('operationId'), + }); + } + }, + }; +} \ No newline at end of file diff --git a/redocly.yaml b/redocly.yaml new file mode 100644 index 00000000..5f17c3e9 --- /dev/null +++ b/redocly.yaml @@ -0,0 +1,11 @@ +apis: + sample@v1: + root: openapi/petstore.yaml +rules: + plugin/operation-id-not-test: + severity: error + operation-4xx-response: + severity: off + +plugins: + - "./plugins/plugin.js"