Skip to content

Commit 3ae5eaa

Browse files
authored
feat: switch new OpenAPI docs to /api/v2 (#1411)
1 parent cbc8ae9 commit 3ae5eaa

File tree

7 files changed

+37
-54
lines changed

7 files changed

+37
-54
lines changed

apify-api/scripts/script-requirements.txt

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

apify-docs-theme/src/theme/custom.css

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1698,6 +1698,7 @@ iframe[src*="youtube"] {
16981698
justify-content: start;
16991699
}
17001700

1701+
.openapi-endpoint.api-method::before,
17011702
.api-method > .menu__link::before,
17021703
.schema > .menu__link::before {
17031704
width: 55px;
@@ -1726,73 +1727,88 @@ iframe[src*="youtube"] {
17261727
}
17271728

17281729
.get > .menu__link::before,
1730+
.openapi-endpoint.api-method.get::before,
17291731
.theme-api-markdown .openapi__method-endpoint .badge--primary {
17301732
background-color: var(--ifm-color-info-contrast-background);
17311733
color: var(--ifm-color-info-contrast-foreground);
17321734
border-color: var(--ifm-color-info-dark);
17331735
}
17341736

1737+
.openapi-endpoint.api-method.get::before,
17351738
.get > .menu__link::before {
17361739
content: 'get';
17371740
}
17381741

1742+
.openapi-endpoint.api-method.post::before,
17391743
.post > .menu__link::before {
17401744
content: 'post';
17411745
}
17421746

17431747
.post > .menu__link::before,
1748+
.openapi-endpoint.api-method.post::before,
17441749
.theme-api-markdown .openapi__method-endpoint .badge--success {
17451750
background-color: var(--ifm-color-success-contrast-background);
17461751
color: var(--ifm-color-success-contrast-foreground);
17471752
border-color: var(--ifm-color-success-dark);
17481753
}
17491754

1755+
.openapi-endpoint.api-method.delete::before,
17501756
.delete > .menu__link::before {
17511757
content: 'del';
17521758
}
17531759

17541760
.delete > .menu__link::before,
1761+
.openapi-endpoint.api-method.delete::before,
17551762
.theme-api-markdown .openapi__method-endpoint .badge--danger {
17561763
background-color: var(--ifm-color-danger-contrast-background);
17571764
color: var(--ifm-color-danger-contrast-foreground);
17581765
border-color: var(--ifm-color-danger-dark);
17591766
}
17601767

1768+
.openapi-endpoint.api-method.put::before,
17611769
.put > .menu__link::before {
17621770
content: 'put';
17631771
}
17641772

17651773
.put > .menu__link::before,
1774+
.openapi-endpoint.api-method.put::before,
17661775
.theme-api-markdown .openapi__method-endpoint .badge--info {
17671776
background-color: var(--ifm-color-warning-contrast-background);
17681777
color: var(--ifm-color-warning-contrast-foreground);
17691778
border-color: var(--ifm-color-warning-dark);
17701779
}
17711780

1781+
.openapi-endpoint.api-method.patch::before,
17721782
.patch > .menu__link::before {
17731783
content: 'patch';
17741784
}
17751785

17761786
.patch > .menu__link::before,
1787+
.openapi-endpoint.api-method.patch::before,
17771788
.theme-api-markdown .openapi__method-endpoint .badge--warning {
17781789
background-color: var(--ifm-color-success-contrast-background);
17791790
color: var(--ifm-color-success-contrast-foreground);
17801791
border-color: var(--ifm-color-success-dark);
17811792
}
17821793

1794+
.openapi-endpoint.api-method.head::before,
17831795
.head > .menu__link::before {
17841796
content: 'head';
17851797
}
17861798

17871799
.head > .menu__link::before,
1800+
.openapi-endpoint.api-method.head::before,
17881801
.event > .menu__link::before,
1802+
.openapi-endpoint.api-method.event::before,
17891803
.schema > .menu__link::before,
1804+
.openapi-endpoint.api-method.schema::before,
17901805
.theme-api-markdown .openapi__method-endpoint .badge--secondary {
17911806
background-color: var(--ifm-color-secondary-contrast-background);
17921807
color: var(--ifm-color-secondary-contrast-foreground);
17931808
border-color: var(--ifm-color-secondary-dark);
17941809
}
17951810

1811+
.openapi-endpoint.api-method.event::before,
17961812
.event > .menu__link::before {
17971813
content: 'event';
17981814
}

apify-docs-theme/static/js/custom.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,7 @@ function scrollOpenApiSidebarItemIntoView() {
7878
function redirectOpenApiDocs() {
7979
const { hash, pathname, origin } = new URL(window.location.href);
8080

81-
// TODO change to '/api/v2'
82-
if (pathname.replace(/\/$/, '') !== '/api/v2-new') {
81+
if (!pathname.startsWith('/api/v2') || pathname.startsWith('/api/v2-')) {
8382
return;
8483
}
8584

@@ -129,5 +128,6 @@ window.addEventListener('load', () => {
129128
});
130129

131130
window.addEventListener('popstate', () => {
131+
setTimeout(() => redirectOpenApiDocs(), 50);
132132
setTimeout(() => scrollOpenApiSidebarItemIntoView(), 50);
133133
});

docusaurus.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ module.exports = {
132132
specs: [
133133
{
134134
spec: './apify-api/openapi/openapi.yaml',
135-
route: '/api/v2/',
135+
route: '/api/v2-redoc/',
136136
},
137137
],
138138
theme: {
@@ -177,7 +177,7 @@ module.exports = {
177177
{
178178
id: 'openapi',
179179
path: './sources/api',
180-
routeBasePath: 'api/v2-new', // TODO change to `api/v2` once we are ready
180+
routeBasePath: 'api/v2',
181181
rehypePlugins: [externalLinkProcessor],
182182
showLastUpdateAuthor: false,
183183
showLastUpdateTime: false,

src/theme/DocCard/index.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ function CardContainer({ href, children }) {
3535
);
3636
}
3737

38-
function CardLayout({ href, icon, title, description }) {
38+
function CardLayout({ href, icon, title, description, className }) {
3939
if (href.startsWith('/api')) {
4040
description = '';
4141
}
@@ -45,7 +45,7 @@ function CardLayout({ href, icon, title, description }) {
4545
href={href}>
4646
<Heading
4747
as="h2"
48-
className={clsx('text--truncate', styles.cardTitle)}
48+
className={clsx('text--truncate', styles.cardTitle, className)}
4949
title={title}>
5050
{icon} {title}
5151
</Heading>
@@ -78,8 +78,20 @@ function CardCategory({ item }) {
7878
}
7979

8080
function CardLink({ item }) {
81-
const icon = isInternalUrl(item.href) ? '📄️' : '🔗';
8281
const doc = useDocById(item.docId ?? undefined);
82+
83+
if (item.href.startsWith('/api/v2')) {
84+
return (
85+
<CardLayout
86+
href={item.href}
87+
title={item.label}
88+
className={clsx('openapi-endpoint', item.className)}
89+
description={item.description ?? doc?.description}
90+
/>
91+
);
92+
}
93+
94+
const icon = isInternalUrl(item.href) ? '📄️' : '🔗';
8395
return (
8496
<CardLayout
8597
href={item.href}

src/theme/DocSidebarItem/Category/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ export default function DocSidebarItemCategory({ item, onItemClick, activePath,
137137
}
138138
}
139139

140-
console.log(item);
140+
// console.log('sidebar category', item);
141141

142142
return (
143143
<li

static/robots.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
User-agent: *
22
Sitemap: https://docs.apify.com/sitemap.xml
33
Disallow: https://docs.apify.com/api/v2-old
4-
Disallow: https://docs.apify.com/api/v2-new
4+
Disallow: https://docs.apify.com/api/v2-redoc

0 commit comments

Comments
 (0)