docs-v2/api-docs/openapi/plugins/docs-plugin.js

59 lines
1.9 KiB
JavaScript
Raw Normal View History

const ReportTags = require('./rules/report-tags');
const ValidateServersUrl = require('./rules/validate-servers-url');
const RemovePrivatePaths = require('./decorators/paths/remove-private-paths');
Fix/api securityschemes (#3488) * fix: oss and cloud auth. Add bearer scheme for OSS. * chore: Add an openapi CLI decorator that replaces INFLUXDB_DOCS_URL 'shortcodes' with the correct URL in specs. * fix: API authentication descriptions and schemes in /api/v2 and V1Compat. Remove QueryString and Basic auth schemes from /api/v2 and add them to V1Compat, along with Token auth. Hook up the replace-docs-url-shortcode which is primarily for V1Compat for now due to the way that contract is managed. Add tag groups to V1Compat. * fix: add v1compat Info description. Comment out Bearer auth in OSS until it's available in Cloud. * fix: add replace-shortcodes decorator. Fix v1-compat tag-groups. Fix spec titles. * fix: restore BasicAuth scheme definition for the users operations that reference them. Still need examples for these. * fix: remove 1.x BasicAuth references where they don't belong. * chore: sync from openapi master. * fix: use replace-shortcodes to replace full Docs URLs in the contracts with absolute local paths to avoid roundtrips. Improve v1compat titles. * Update api-docs/cloud/swaggerV1Compat.yml Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com> * Update api-docs/cloud/swaggerV1Compat.yml Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com> * Update api-docs/cloud/swaggerV1Compat.yml Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com> * Update api-docs/cloud/swaggerV1Compat.yml Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com> * Update api-docs/cloud/swaggerV1Compat.yml Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com> Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com>
2021-12-21 20:34:49 +00:00
const ReplaceShortcodes = require('./decorators/replace-shortcodes');
const SetInfo = require('./decorators/set-info');
const SetServers = require('./decorators/servers/set-servers');
const SetSecuritySchemes = require('./decorators/security/set-security-schemes');
const SetTags = require('./decorators/tags/set-tags');
const SetTagGroups = require('./decorators/tags/set-tag-groups');
const StripVersionPrefix = require('./decorators/paths/strip-version-prefix');
const {info, securitySchemes, servers, tags, tagGroups } = require('../content/content')
const id = 'docs';
/** @type {import('@redocly/openapi-cli').CustomRulesConfig} */
const rules = {
oas3: {
'validate-servers-url': ValidateServersUrl,
'report-tags': ReportTags,
}
};
/** @type {import('@redocly/openapi-cli').CustomRulesConfig} */
const decorators = {
oas3: {
'set-servers': () => SetServers({data: servers}),
'remove-private-paths': RemovePrivatePaths,
Fix/api securityschemes (#3488) * fix: oss and cloud auth. Add bearer scheme for OSS. * chore: Add an openapi CLI decorator that replaces INFLUXDB_DOCS_URL 'shortcodes' with the correct URL in specs. * fix: API authentication descriptions and schemes in /api/v2 and V1Compat. Remove QueryString and Basic auth schemes from /api/v2 and add them to V1Compat, along with Token auth. Hook up the replace-docs-url-shortcode which is primarily for V1Compat for now due to the way that contract is managed. Add tag groups to V1Compat. * fix: add v1compat Info description. Comment out Bearer auth in OSS until it's available in Cloud. * fix: add replace-shortcodes decorator. Fix v1-compat tag-groups. Fix spec titles. * fix: restore BasicAuth scheme definition for the users operations that reference them. Still need examples for these. * fix: remove 1.x BasicAuth references where they don't belong. * chore: sync from openapi master. * fix: use replace-shortcodes to replace full Docs URLs in the contracts with absolute local paths to avoid roundtrips. Improve v1compat titles. * Update api-docs/cloud/swaggerV1Compat.yml Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com> * Update api-docs/cloud/swaggerV1Compat.yml Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com> * Update api-docs/cloud/swaggerV1Compat.yml Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com> * Update api-docs/cloud/swaggerV1Compat.yml Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com> * Update api-docs/cloud/swaggerV1Compat.yml Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com> Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com>
2021-12-21 20:34:49 +00:00
'replace-docs-url-shortcode': ReplaceShortcodes().docsUrl,
'strip-version-prefix': StripVersionPrefix,
'set-info': () => SetInfo({data: info}),
'set-security': () => SetSecurity({data: security}),
'set-security-schemes': () => SetSecuritySchemes({data: securitySchemes}),
'set-tags': () => SetTags({data: tags}),
'set-tag-groups': () => SetTagGroups({data: tagGroups}),
}
};
module.exports = {
id,
configs: {
all: {
rules: {
'no-server-trailing-slash': 'off',
'docs/validate-servers-url': 'error',
},
decorators: {
'docs/set-servers': 'error',
'docs/remove-private-paths': 'error',
Fix/api securityschemes (#3488) * fix: oss and cloud auth. Add bearer scheme for OSS. * chore: Add an openapi CLI decorator that replaces INFLUXDB_DOCS_URL 'shortcodes' with the correct URL in specs. * fix: API authentication descriptions and schemes in /api/v2 and V1Compat. Remove QueryString and Basic auth schemes from /api/v2 and add them to V1Compat, along with Token auth. Hook up the replace-docs-url-shortcode which is primarily for V1Compat for now due to the way that contract is managed. Add tag groups to V1Compat. * fix: add v1compat Info description. Comment out Bearer auth in OSS until it's available in Cloud. * fix: add replace-shortcodes decorator. Fix v1-compat tag-groups. Fix spec titles. * fix: restore BasicAuth scheme definition for the users operations that reference them. Still need examples for these. * fix: remove 1.x BasicAuth references where they don't belong. * chore: sync from openapi master. * fix: use replace-shortcodes to replace full Docs URLs in the contracts with absolute local paths to avoid roundtrips. Improve v1compat titles. * Update api-docs/cloud/swaggerV1Compat.yml Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com> * Update api-docs/cloud/swaggerV1Compat.yml Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com> * Update api-docs/cloud/swaggerV1Compat.yml Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com> * Update api-docs/cloud/swaggerV1Compat.yml Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com> * Update api-docs/cloud/swaggerV1Compat.yml Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com> Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com>
2021-12-21 20:34:49 +00:00
'docs/replace-docs-url-shortcode': 'error',
'docs/strip-version-prefix': 'error',
'docs/set-info': 'error',
'docs/set-tag-groups': 'error',
},
},
},
decorators,
rules
};