Skip to content

Commit e9375aa

Browse files
committed
chore: migrate config files, migrate redoc plugin to ESM
1 parent 9a34c30 commit e9375aa

File tree

6 files changed

+28
-30
lines changed

6 files changed

+28
-30
lines changed

apify-api/plugins/apify.js

Lines changed: 0 additions & 14 deletions
This file was deleted.

apify-api/plugins/apify.mjs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import ClientReferencesLinksDecorator from './decorators/client-references-links-decorator.mjs';
2+
import CodeSamplesDecorator from './decorators/code-samples-decorator.mjs';
3+
import LegacyDocUrlDecorator from './decorators/legacy-doc-url-decorator.mjs';
4+
5+
export default () => ({
6+
id: 'apify',
7+
decorators: {
8+
oas3: {
9+
'legacy-doc-url-decorator': LegacyDocUrlDecorator,
10+
'client-references-links-decorator': ClientReferencesLinksDecorator,
11+
'code-samples-decorator': CodeSamplesDecorator,
12+
},
13+
},
14+
});

apify-api/plugins/decorators/client-references-links-decorator.js renamed to apify-api/plugins/decorators/client-references-links-decorator.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ function ClientReferencesLinksDecorator(target) {
6363
target.description = `${prepend}${target.description || ''}`;
6464
}
6565

66-
module.exports = () => ({
66+
export default () => ({
6767
// Redocly is using a visitor pattern. What the following code does is that whenever the traverser leaves a node of
6868
// type Tag or Operation, it executes prependLegacyUrlAnchor on it.
6969
Tag: {

apify-api/plugins/decorators/code-samples-decorator.js renamed to apify-api/plugins/decorators/code-samples-decorator.mjs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
const { existsSync } = require('node:fs');
2-
const path = require('node:path');
1+
import { existsSync } from 'node:fs';
2+
import path from 'node:path';
33

44
const X_CODE_SAMPLES_PROPERTY = 'x-codeSamples';
55

@@ -31,7 +31,7 @@ function CodeSamplesDecorator(target) {
3131

3232
for (const { lang, label, langSuffix } of LANGUAGES) {
3333
const codeSamplePath = path.join(
34-
__dirname,
34+
import.meta.dirname,
3535
`../../openapi/code_samples/${lang.toLowerCase()}/${operationId}.${langSuffix}`,
3636
);
3737

@@ -55,7 +55,7 @@ function CodeSamplesDecorator(target) {
5555
}
5656
}
5757

58-
module.exports = () => ({
58+
export default () => ({
5959
// Redocly is using a visitor pattern. What the following code does is that whenever the traverser leaves a node of
6060
// type Tag or Operation, it executes CodeSamplesDecorator on it.
6161
Tag: {

apify-api/plugins/decorators/legacy-doc-url-decorator.js renamed to apify-api/plugins/decorators/legacy-doc-url-decorator.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ function prependLegacyUrlAnchor(target) {
3737
}
3838
}
3939

40-
module.exports = () => ({
40+
export default () => ({
4141
// Redocly is using a visitor pattern. What the following code does is that whenever the traverser leaves a node of
4242
// type Tag or Operation, it executes prependLegacyUrlAnchor on it.
4343
Tag: {

redocly.yaml

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,19 @@ extends:
88

99
rules:
1010
# TODO we have quite a lot of errors in there, once we fix them, this should be flipped to `error` too
11-
spec: warn
11+
struct: warn
1212
no-unused-components: error
1313

14-
theme:
14+
openapi:
1515
htmlTemplate: openapi/docs/index.html
16-
17-
openapi:
18-
expandDefaultResponse: true
19-
expandDefaultRequest: true
20-
expandResponses: all
21-
schemasExpansionLevel: 2
22-
jsonSamplesExpandLevel: 2
16+
expandDefaultResponse: true
17+
expandDefaultRequest: true
18+
expandResponses: all
19+
schemasExpansionLevel: 2
20+
jsonSamplesExpandLevel: 2
2321

2422
plugins:
25-
- apify-api/plugins/apify.js
23+
- apify-api/plugins/apify.mjs
2624

2725
decorators:
2826
apify/legacy-doc-url-decorator: on

0 commit comments

Comments
 (0)