Skip to content

Commit 97cf583

Browse files
authored
Merge pull request linode#43 from linode/DLC-169
Switch locations for API specs
2 parents 6d8363d + ed24152 commit 97cf583

File tree

7 files changed

+26
-27
lines changed

7 files changed

+26
-27
lines changed

gatsby-config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ module.exports = {
126126
resolve: `gatsby-source-filesystem`,
127127
options: {
128128
name: `data`,
129-
path: `${__dirname}/src/data`
129+
path: `${__dirname}/static/api/docs/v4`
130130
}
131131
},
132132
{

gatsby-node.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const path = require("path");
33
const _ = require("lodash");
44
const fs = require("fs");
55

6-
const specs = require("./src/data/spec.json");
6+
const specs = require("./static/api/docs/v4/spec.json");
77
const crypto = require("crypto");
88
const parser = new JsonSchemaRefParser();
99

getDependencies.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ fi
1212
echo
1313
echo "${BLUE}Fetching API specs${NC}"
1414
cd -
15-
curl https://developers.linode.com/api/docs/v4/openapi.yaml > src/data/openapi.yaml
15+
curl https://raw.githubusercontent.com/linode/linode-api-docs/master/openapi.yaml > static/api/docs/v4/openapi.yaml
1616

1717
echo
1818
echo "${BLUE}Removing faulty data${NC}"
19-
sed -i.bak '/backgroundColor:/d' src/data/openapi.yaml
20-
rm src/data/openapi.yaml.bak
19+
sed -i.bak '/backgroundColor:/d' static/api/docs/v4/openapi.yaml
20+
rm static/api/docs/v4/openapi.yaml.bak
2121

2222
echo
2323
echo "${BLUE}Converting YAML to JSON${NC}"
24-
./node_modules/yamljs/bin/yaml2json src/data/openapi.yaml > src/data/spec.json
24+
./node_modules/yamljs/bin/yaml2json static/api/docs/v4/openapi.yaml > static/api/docs/v4/spec.json

search/buildIndex.js

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,22 @@
1-
const fs = require('fs');
2-
const _ = require('lodash');
3-
const md5 = require('md5');
4-
const buildAlgolia = require('./buildAlgolia');
5-
require('dotenv').config();
1+
const fs = require("fs");
2+
const _ = require("lodash");
3+
const md5 = require("md5");
4+
const buildAlgolia = require("./buildAlgolia");
5+
require("dotenv").config();
66

77
// This assumes the version of the spec in data/ is the current version
8-
const spec = require('../src/data/spec.json');
9-
10-
const BASE_URL = 'https://developers.linode.com/api/v4/';
8+
const spec = require("../static/api/docs/v4/spec.json");
119

10+
const BASE_URL = "https://developers.linode.com/api/v4/";
1211

1312
const buildIndex = () => {
1413
const index = [];
1514
for (const [key, value] of Object.entries(spec.paths)) {
1615
const methodNames = Object.keys(value);
17-
16+
1817
methodNames.forEach(methodName => {
19-
const entry = {}
20-
if (['get', 'put', 'post', 'delete'].includes(methodName)) {
18+
const entry = {};
19+
if (["get", "put", "post", "delete"].includes(methodName)) {
2120
const thisMethod = value[methodName];
2221
entry.name = thisMethod.summary;
2322
entry.tags = thisMethod.tags;
@@ -27,14 +26,14 @@ const buildIndex = () => {
2726
index.push(entry);
2827
}
2928
});
30-
};
29+
}
3130
return index;
32-
}
31+
};
3332

34-
const getUrl = (endpoint) => {
33+
const getUrl = endpoint => {
3534
const url = _.kebabCase(endpoint);
3635
return BASE_URL + url;
37-
}
36+
};
3837

3938
// Generate an array of objects representing index entries
4039
const index = buildIndex();
@@ -43,8 +42,8 @@ const index = buildIndex();
4342
buildAlgolia(index);
4443

4544
// Save a copy of the index to file for reference.
46-
fs.writeFile('index.json', JSON.stringify(index), (err) => {
45+
fs.writeFile("index.json", JSON.stringify(index), err => {
4746
if (err) {
4847
console.error(err);
4948
}
50-
});
49+
});

src/components/1_atoms/APITitle.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React from "react";
22
import { StaticQuery, graphql } from "gatsby";
33

44
const APITitle = ({ data }) => {
5-
const n = data.allDataJson.edges[0].node;
5+
const n = data.allV4Json.edges[0].node;
66

77
return (
88
<div className="mb-4">
@@ -15,7 +15,7 @@ export default props => (
1515
<StaticQuery
1616
query={graphql`
1717
query {
18-
allDataJson {
18+
allV4Json {
1919
edges {
2020
node {
2121
info {

src/pages/api/v4.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class APIDocs extends React.Component {
4141
}
4242

4343
render() {
44-
const n = this.props.data.allDataJson.edges[0].node;
44+
const n = this.props.data.allV4Json.edges[0].node;
4545

4646
return (
4747
<Layout
@@ -86,7 +86,7 @@ export default props => (
8686
<StaticQuery
8787
query={graphql`
8888
query {
89-
allDataJson {
89+
allV4Json {
9090
edges {
9191
node {
9292
info {
File renamed without changes.

0 commit comments

Comments
 (0)