hotfix: docs build (#198)
* fix: build * fix: build * fix: build * fix: build
This commit is contained in:
+7954
-1
File diff suppressed because one or more lines are too long
+153
-153
@@ -695,49 +695,6 @@ paths:
|
|||||||
properties:
|
properties:
|
||||||
discount:
|
discount:
|
||||||
$ref: '#/components/schemas/discount'
|
$ref: '#/components/schemas/discount'
|
||||||
/notifications:
|
|
||||||
get:
|
|
||||||
operationId: GetNotifications
|
|
||||||
summary: List Notifications
|
|
||||||
description: Retrieves a list of Notifications.
|
|
||||||
tags:
|
|
||||||
- Notification
|
|
||||||
responses:
|
|
||||||
'200':
|
|
||||||
description: OK
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
properties:
|
|
||||||
notifications:
|
|
||||||
type: array
|
|
||||||
items:
|
|
||||||
$ref: '#/components/schemas/notification'
|
|
||||||
'/notifications/{id}/resend':
|
|
||||||
post:
|
|
||||||
operationId: PostNotificationsNotificationResend
|
|
||||||
summary: Resend Notification
|
|
||||||
description: >-
|
|
||||||
Resends a previously sent notifications, with the same data but
|
|
||||||
optionally to a different address
|
|
||||||
parameters:
|
|
||||||
- in: path
|
|
||||||
name: id
|
|
||||||
required: true
|
|
||||||
description: The id of the Notification
|
|
||||||
schema:
|
|
||||||
type: string
|
|
||||||
tags:
|
|
||||||
- Notification
|
|
||||||
responses:
|
|
||||||
'200':
|
|
||||||
description: OK
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
properties:
|
|
||||||
notification:
|
|
||||||
$ref: '#/components/schemas/notification'
|
|
||||||
/gift-cards:
|
/gift-cards:
|
||||||
post:
|
post:
|
||||||
operationId: PostGiftCards
|
operationId: PostGiftCards
|
||||||
@@ -910,6 +867,49 @@ paths:
|
|||||||
properties:
|
properties:
|
||||||
gift_card:
|
gift_card:
|
||||||
$ref: '#/components/schemas/gift_card'
|
$ref: '#/components/schemas/gift_card'
|
||||||
|
/notifications:
|
||||||
|
get:
|
||||||
|
operationId: GetNotifications
|
||||||
|
summary: List Notifications
|
||||||
|
description: Retrieves a list of Notifications.
|
||||||
|
tags:
|
||||||
|
- Notification
|
||||||
|
responses:
|
||||||
|
'200':
|
||||||
|
description: OK
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
properties:
|
||||||
|
notifications:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
$ref: '#/components/schemas/notification'
|
||||||
|
'/notifications/{id}/resend':
|
||||||
|
post:
|
||||||
|
operationId: PostNotificationsNotificationResend
|
||||||
|
summary: Resend Notification
|
||||||
|
description: >-
|
||||||
|
Resends a previously sent notifications, with the same data but
|
||||||
|
optionally to a different address
|
||||||
|
parameters:
|
||||||
|
- in: path
|
||||||
|
name: id
|
||||||
|
required: true
|
||||||
|
description: The id of the Notification
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
tags:
|
||||||
|
- Notification
|
||||||
|
responses:
|
||||||
|
'200':
|
||||||
|
description: OK
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
properties:
|
||||||
|
notification:
|
||||||
|
$ref: '#/components/schemas/notification'
|
||||||
'/orders/{id}/shipping-methods':
|
'/orders/{id}/shipping-methods':
|
||||||
post:
|
post:
|
||||||
operationId: PostOrdersOrderShippingMethods
|
operationId: PostOrdersOrderShippingMethods
|
||||||
@@ -3358,116 +3358,6 @@ paths:
|
|||||||
properties:
|
properties:
|
||||||
shipping_option:
|
shipping_option:
|
||||||
$ref: '#/components/schemas/shipping_option'
|
$ref: '#/components/schemas/shipping_option'
|
||||||
'/store/currencies/{code}':
|
|
||||||
post:
|
|
||||||
operationId: PostStoreCurrenciesCode
|
|
||||||
summary: Add a Currency Code
|
|
||||||
description: Adds a Currency Code to the available currencies.
|
|
||||||
parameters:
|
|
||||||
- in: path
|
|
||||||
name: code
|
|
||||||
required: true
|
|
||||||
description: The 3 character ISO currency code.
|
|
||||||
schema:
|
|
||||||
type: string
|
|
||||||
tags:
|
|
||||||
- Store
|
|
||||||
responses:
|
|
||||||
'200':
|
|
||||||
description: OK
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
properties:
|
|
||||||
store:
|
|
||||||
$ref: '#/components/schemas/store'
|
|
||||||
delete:
|
|
||||||
operationId: DeleteStoreCurrenciesCode
|
|
||||||
summary: Remvoe a Currency Code
|
|
||||||
description: Removes a Currency Code from the available currencies.
|
|
||||||
parameters:
|
|
||||||
- in: path
|
|
||||||
name: code
|
|
||||||
required: true
|
|
||||||
description: The 3 character ISO currency code.
|
|
||||||
schema:
|
|
||||||
type: string
|
|
||||||
tags:
|
|
||||||
- Store
|
|
||||||
responses:
|
|
||||||
'200':
|
|
||||||
description: OK
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
properties:
|
|
||||||
store:
|
|
||||||
$ref: '#/components/schemas/store'
|
|
||||||
/store:
|
|
||||||
get:
|
|
||||||
operationId: GetStore
|
|
||||||
summary: Retrieve Store details.
|
|
||||||
description: Retrieves the Store details
|
|
||||||
tags:
|
|
||||||
- Store
|
|
||||||
responses:
|
|
||||||
'200':
|
|
||||||
description: OK
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
properties:
|
|
||||||
store:
|
|
||||||
$ref: '#/components/schemas/store'
|
|
||||||
post:
|
|
||||||
operationId: PostStore
|
|
||||||
summary: Update Store details.
|
|
||||||
description: Updates the Store details
|
|
||||||
requestBody:
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
properties:
|
|
||||||
name:
|
|
||||||
description: The name of the Store
|
|
||||||
type: string
|
|
||||||
swap_link_template:
|
|
||||||
description: >-
|
|
||||||
A template for Swap links - use `{{cart_id}}` to insert the
|
|
||||||
Swap Cart id
|
|
||||||
type: string
|
|
||||||
default_currency_code:
|
|
||||||
description: The default currency code for the Store.
|
|
||||||
type: string
|
|
||||||
tags:
|
|
||||||
- Store
|
|
||||||
responses:
|
|
||||||
'200':
|
|
||||||
description: OK
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
properties:
|
|
||||||
store:
|
|
||||||
$ref: '#/components/schemas/store'
|
|
||||||
/store/payment-providers:
|
|
||||||
get:
|
|
||||||
operationId: GetStorePaymentProviders
|
|
||||||
summary: Retrieve configured Payment Providers
|
|
||||||
description: Retrieves the configured Payment Providers
|
|
||||||
tags:
|
|
||||||
- Store
|
|
||||||
responses:
|
|
||||||
'200':
|
|
||||||
description: OK
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
properties:
|
|
||||||
payment_providers:
|
|
||||||
type: array
|
|
||||||
items:
|
|
||||||
$ref: '#/components/schemas/store'
|
|
||||||
/shipping-profiles:
|
/shipping-profiles:
|
||||||
post:
|
post:
|
||||||
operationId: PostShippingProfiles
|
operationId: PostShippingProfiles
|
||||||
@@ -3590,6 +3480,116 @@ paths:
|
|||||||
properties:
|
properties:
|
||||||
shipping_profiles:
|
shipping_profiles:
|
||||||
$ref: '#/components/schemas/shipping_profile'
|
$ref: '#/components/schemas/shipping_profile'
|
||||||
|
'/store/currencies/{code}':
|
||||||
|
post:
|
||||||
|
operationId: PostStoreCurrenciesCode
|
||||||
|
summary: Add a Currency Code
|
||||||
|
description: Adds a Currency Code to the available currencies.
|
||||||
|
parameters:
|
||||||
|
- in: path
|
||||||
|
name: code
|
||||||
|
required: true
|
||||||
|
description: The 3 character ISO currency code.
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
tags:
|
||||||
|
- Store
|
||||||
|
responses:
|
||||||
|
'200':
|
||||||
|
description: OK
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
properties:
|
||||||
|
store:
|
||||||
|
$ref: '#/components/schemas/store'
|
||||||
|
delete:
|
||||||
|
operationId: DeleteStoreCurrenciesCode
|
||||||
|
summary: Remvoe a Currency Code
|
||||||
|
description: Removes a Currency Code from the available currencies.
|
||||||
|
parameters:
|
||||||
|
- in: path
|
||||||
|
name: code
|
||||||
|
required: true
|
||||||
|
description: The 3 character ISO currency code.
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
tags:
|
||||||
|
- Store
|
||||||
|
responses:
|
||||||
|
'200':
|
||||||
|
description: OK
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
properties:
|
||||||
|
store:
|
||||||
|
$ref: '#/components/schemas/store'
|
||||||
|
/store:
|
||||||
|
get:
|
||||||
|
operationId: GetStore
|
||||||
|
summary: Retrieve Store details.
|
||||||
|
description: Retrieves the Store details
|
||||||
|
tags:
|
||||||
|
- Store
|
||||||
|
responses:
|
||||||
|
'200':
|
||||||
|
description: OK
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
properties:
|
||||||
|
store:
|
||||||
|
$ref: '#/components/schemas/store'
|
||||||
|
post:
|
||||||
|
operationId: PostStore
|
||||||
|
summary: Update Store details.
|
||||||
|
description: Updates the Store details
|
||||||
|
requestBody:
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
properties:
|
||||||
|
name:
|
||||||
|
description: The name of the Store
|
||||||
|
type: string
|
||||||
|
swap_link_template:
|
||||||
|
description: >-
|
||||||
|
A template for Swap links - use `{{cart_id}}` to insert the
|
||||||
|
Swap Cart id
|
||||||
|
type: string
|
||||||
|
default_currency_code:
|
||||||
|
description: The default currency code for the Store.
|
||||||
|
type: string
|
||||||
|
tags:
|
||||||
|
- Store
|
||||||
|
responses:
|
||||||
|
'200':
|
||||||
|
description: OK
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
properties:
|
||||||
|
store:
|
||||||
|
$ref: '#/components/schemas/store'
|
||||||
|
/store/payment-providers:
|
||||||
|
get:
|
||||||
|
operationId: GetStorePaymentProviders
|
||||||
|
summary: Retrieve configured Payment Providers
|
||||||
|
description: Retrieves the configured Payment Providers
|
||||||
|
tags:
|
||||||
|
- Store
|
||||||
|
responses:
|
||||||
|
'200':
|
||||||
|
description: OK
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
properties:
|
||||||
|
payment_providers:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
$ref: '#/components/schemas/store'
|
||||||
/swaps:
|
/swaps:
|
||||||
get:
|
get:
|
||||||
operationId: GetSwaps
|
operationId: GetSwaps
|
||||||
|
|||||||
+4575
-1
File diff suppressed because one or more lines are too long
+50
-50
@@ -1025,6 +1025,56 @@ paths:
|
|||||||
properties:
|
properties:
|
||||||
customer:
|
customer:
|
||||||
$ref: '#/components/schemas/customer'
|
$ref: '#/components/schemas/customer'
|
||||||
|
'/products/{id}':
|
||||||
|
get:
|
||||||
|
operationId: GetProductsProduct
|
||||||
|
summary: Retrieves a Product
|
||||||
|
description: Retrieves a Product.
|
||||||
|
parameters:
|
||||||
|
- in: path
|
||||||
|
name: id
|
||||||
|
required: true
|
||||||
|
description: The id of the Product.
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
tags:
|
||||||
|
- Product
|
||||||
|
responses:
|
||||||
|
'200':
|
||||||
|
description: OK
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
properties:
|
||||||
|
product:
|
||||||
|
$ref: '#/components/schemas/product'
|
||||||
|
/products:
|
||||||
|
get:
|
||||||
|
operationId: GetProducts
|
||||||
|
summary: List Products
|
||||||
|
description: Retrieves a list of Products.
|
||||||
|
tags:
|
||||||
|
- Product
|
||||||
|
responses:
|
||||||
|
'200':
|
||||||
|
description: OK
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
properties:
|
||||||
|
count:
|
||||||
|
description: The total number of Products.
|
||||||
|
type: integer
|
||||||
|
offset:
|
||||||
|
description: The offset for pagination.
|
||||||
|
type: integer
|
||||||
|
limit:
|
||||||
|
description: 'The maxmimum number of Products to return,'
|
||||||
|
type: integer
|
||||||
|
products:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
$ref: '#/components/schemas/product'
|
||||||
'/regions/{id}':
|
'/regions/{id}':
|
||||||
get:
|
get:
|
||||||
operationId: GetRegionsRegion
|
operationId: GetRegionsRegion
|
||||||
@@ -1129,56 +1179,6 @@ paths:
|
|||||||
type: array
|
type: array
|
||||||
items:
|
items:
|
||||||
$ref: '#/components/schemas/shipping_option'
|
$ref: '#/components/schemas/shipping_option'
|
||||||
'/products/{id}':
|
|
||||||
get:
|
|
||||||
operationId: GetProductsProduct
|
|
||||||
summary: Retrieves a Product
|
|
||||||
description: Retrieves a Product.
|
|
||||||
parameters:
|
|
||||||
- in: path
|
|
||||||
name: id
|
|
||||||
required: true
|
|
||||||
description: The id of the Product.
|
|
||||||
schema:
|
|
||||||
type: string
|
|
||||||
tags:
|
|
||||||
- Product
|
|
||||||
responses:
|
|
||||||
'200':
|
|
||||||
description: OK
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
properties:
|
|
||||||
product:
|
|
||||||
$ref: '#/components/schemas/product'
|
|
||||||
/products:
|
|
||||||
get:
|
|
||||||
operationId: GetProducts
|
|
||||||
summary: List Products
|
|
||||||
description: Retrieves a list of Products.
|
|
||||||
tags:
|
|
||||||
- Product
|
|
||||||
responses:
|
|
||||||
'200':
|
|
||||||
description: OK
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
properties:
|
|
||||||
count:
|
|
||||||
description: The total number of Products.
|
|
||||||
type: integer
|
|
||||||
offset:
|
|
||||||
description: The offset for pagination.
|
|
||||||
type: integer
|
|
||||||
limit:
|
|
||||||
description: 'The maxmimum number of Products to return,'
|
|
||||||
type: integer
|
|
||||||
products:
|
|
||||||
type: array
|
|
||||||
items:
|
|
||||||
$ref: '#/components/schemas/product'
|
|
||||||
'/swaps/{cart_id}':
|
'/swaps/{cart_id}':
|
||||||
get:
|
get:
|
||||||
operationId: GetSwapsSwapCartId
|
operationId: GetSwapsSwapCartId
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ swaggerInline(
|
|||||||
console.error(err);
|
console.error(err);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
fs.writeFileSync("./docs/api/store-spec3.json", JSON.stringify(genObj));
|
fs.writeFileSync("./docs/api/store-spec3.json", gen);
|
||||||
}, true);
|
}, true);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -44,7 +44,7 @@ swaggerInline(
|
|||||||
console.error(err);
|
console.error(err);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
fs.writeFileSync("./docs/api/admin-spec3.json", JSON.stringify(genObj));
|
fs.writeFileSync("./docs/api/admin-spec3.json", gen);
|
||||||
}, true);
|
}, true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ module.exports = {
|
|||||||
offset: -300,
|
offset: -300,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
`gatsby-transformer-yaml`,
|
`gatsby-transformer-json`,
|
||||||
`gatsby-plugin-emotion`,
|
`gatsby-plugin-emotion`,
|
||||||
{
|
{
|
||||||
resolve: `gatsby-source-filesystem`,
|
resolve: `gatsby-source-filesystem`,
|
||||||
|
|||||||
@@ -23,6 +23,7 @@
|
|||||||
"gatsby-plugin-emotion": "^5.0.0",
|
"gatsby-plugin-emotion": "^5.0.0",
|
||||||
"gatsby-plugin-react-helmet": "^3.3.12",
|
"gatsby-plugin-react-helmet": "^3.3.12",
|
||||||
"gatsby-source-filesystem": "^2.3.31",
|
"gatsby-source-filesystem": "^2.3.31",
|
||||||
|
"gatsby-transformer-json": "^3.0.0",
|
||||||
"gatsby-transformer-yaml": "^2.4.13",
|
"gatsby-transformer-yaml": "^2.4.13",
|
||||||
"react": "^16.12.0",
|
"react": "^16.12.0",
|
||||||
"react-collapsible": "^2.8.1",
|
"react-collapsible": "^2.8.1",
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import React from "react"
|
import React from "react"
|
||||||
import { Flex, Box, Text } from "rebass"
|
import { Flex, Text } from "rebass"
|
||||||
import styled from "@emotion/styled"
|
import styled from "@emotion/styled"
|
||||||
import Markdown from "react-markdown"
|
import Markdown from "react-markdown"
|
||||||
|
|
||||||
@@ -68,10 +68,14 @@ const DocsReader = ({ tags, spec }) => {
|
|||||||
path={endpoint.path}
|
path={endpoint.path}
|
||||||
/>
|
/>
|
||||||
<Markdown>{endpoint.description}</Markdown>
|
<Markdown>{endpoint.description}</Markdown>
|
||||||
<Parameters endpoint={endpoint} />
|
<Parameters spec={spec} endpoint={endpoint} />
|
||||||
</Flex>
|
</Flex>
|
||||||
<Flex py={5} width="45%" flex="1">
|
<Flex py={5} width="45%" flex="1">
|
||||||
<JsonBox name={tagName} endpoint={endpoint} />
|
<JsonBox
|
||||||
|
name={tagName}
|
||||||
|
endpoint={endpoint}
|
||||||
|
spec={spec}
|
||||||
|
/>
|
||||||
</Flex>
|
</Flex>
|
||||||
</Flex>
|
</Flex>
|
||||||
))}
|
))}
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ const EndpointOverview = ({ title, description, routes, spec }) => {
|
|||||||
>
|
>
|
||||||
<Text my={2}>Attributes</Text>
|
<Text my={2}>Attributes</Text>
|
||||||
{attrs.map(p => (
|
{attrs.map(p => (
|
||||||
<ParamSection param={p} />
|
<ParamSection param={p} spec={spec} />
|
||||||
))}
|
))}
|
||||||
</Box>
|
</Box>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -1,15 +1,14 @@
|
|||||||
import React, { useState, useEffect } from "react"
|
import React from "react"
|
||||||
import { graphql } from "gatsby"
|
import { Flex, Box, Text } from "rebass"
|
||||||
import { Flex, Box, Text, Image } from "rebass"
|
|
||||||
import styled from "@emotion/styled"
|
import styled from "@emotion/styled"
|
||||||
import { AnchorLink } from "gatsby-plugin-anchor-links"
|
|
||||||
import Markdown from "react-markdown"
|
|
||||||
import Highlight from "react-highlight.js"
|
import Highlight from "react-highlight.js"
|
||||||
|
|
||||||
import "highlight.js/styles/a11y-light.css"
|
import "highlight.js/styles/a11y-light.css"
|
||||||
|
|
||||||
import fixtures from "../../../docs/api/fixtures.json"
|
import fixtures from "../../../docs/api/fixtures.json"
|
||||||
|
|
||||||
|
import { deref } from "../utils/deref"
|
||||||
|
|
||||||
export const ResponseContainer = styled(Flex)`
|
export const ResponseContainer = styled(Flex)`
|
||||||
border: 1px solid #e3e8ee;
|
border: 1px solid #e3e8ee;
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
@@ -28,36 +27,40 @@ export const ResponseContainer = styled(Flex)`
|
|||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|
||||||
const JsonBox = ({ text, resourceId, endpoint }) => {
|
const JsonBox = ({ text, resourceId, endpoint, spec }) => {
|
||||||
const [json, setJson] = useState({})
|
let json = {}
|
||||||
|
|
||||||
useEffect(() => {
|
const toSet = {}
|
||||||
const toSet = {}
|
if (endpoint) {
|
||||||
if (endpoint) {
|
const props =
|
||||||
const props =
|
endpoint?.responses?.["200"]?.content?.["application/json"]?.schema
|
||||||
endpoint?.responses?.["200"]?.content?.["application/json"]?.schema
|
?.properties
|
||||||
?.properties
|
|
||||||
|
|
||||||
if (props) {
|
if (props) {
|
||||||
for (const [name, details] of Object.entries(props)) {
|
for (const [name, details] of Object.entries(props)) {
|
||||||
if (
|
let cleanDets = details
|
||||||
details["x-resourceId"] &&
|
if (details.$ref) {
|
||||||
details["x-resourceId"] in fixtures.resources
|
const [, ...path] = details.$ref.split("/")
|
||||||
) {
|
cleanDets = deref(path, spec)
|
||||||
toSet[name] = fixtures.resources[details["x-resourceId"]]
|
}
|
||||||
} else {
|
|
||||||
toSet[name] = details
|
if (
|
||||||
}
|
cleanDets["x-resourceId"] &&
|
||||||
|
cleanDets["x-resourceId"] in fixtures.resources
|
||||||
|
) {
|
||||||
|
toSet[name] = fixtures.resources[cleanDets["x-resourceId"]]
|
||||||
|
} else {
|
||||||
|
toSet[name] = cleanDets
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (resourceId) {
|
if (resourceId) {
|
||||||
setJson(fixtures.resources[resourceId])
|
json = fixtures.resources[resourceId]
|
||||||
} else {
|
} else {
|
||||||
setJson(toSet)
|
json = toSet
|
||||||
}
|
}
|
||||||
}, [])
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ResponseContainer flexDirection="column" as="pre">
|
<ResponseContainer flexDirection="column" as="pre">
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ import { Flex, Box, Text } from "rebass"
|
|||||||
import Markdown from "react-markdown"
|
import Markdown from "react-markdown"
|
||||||
import Collapsible from "react-collapsible"
|
import Collapsible from "react-collapsible"
|
||||||
|
|
||||||
|
import { deref } from "../utils/deref"
|
||||||
|
|
||||||
const ExpandContainer = styled.div`
|
const ExpandContainer = styled.div`
|
||||||
.child-attrs {
|
.child-attrs {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
@@ -28,15 +30,27 @@ const ExpandContainer = styled.div`
|
|||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|
||||||
const Expand = ({ schema }) => {
|
const Expand = ({ schema, spec }) => {
|
||||||
|
if (schema.$ref) {
|
||||||
|
const [, ...path] = schema.$ref.split("/")
|
||||||
|
schema = deref(path, spec)
|
||||||
|
}
|
||||||
|
|
||||||
const properties = schema.properties
|
const properties = schema.properties
|
||||||
|
|
||||||
let aggregated = []
|
let aggregated = []
|
||||||
for (const [name, details] of Object.entries(properties)) {
|
for (const [name, details] of Object.entries(properties)) {
|
||||||
|
let cleanDets = details
|
||||||
|
|
||||||
|
if (name === "$ref") {
|
||||||
|
const [, ...path] = details.split("/")
|
||||||
|
cleanDets = deref(path, spec)
|
||||||
|
}
|
||||||
|
|
||||||
if (!aggregated.find(a => a.name === name)) {
|
if (!aggregated.find(a => a.name === name)) {
|
||||||
aggregated.push({
|
aggregated.push({
|
||||||
name,
|
name,
|
||||||
...details,
|
...cleanDets,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -104,7 +118,7 @@ const Expand = ({ schema }) => {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const ParamSection = ({ routeParam, param }) => {
|
const ParamSection = ({ routeParam, param, spec }) => {
|
||||||
let type = param.type
|
let type = param.type
|
||||||
if (!type && param.schema) {
|
if (!type && param.schema) {
|
||||||
type = param.schema.type
|
type = param.schema.type
|
||||||
@@ -133,10 +147,12 @@ const ParamSection = ({ routeParam, param }) => {
|
|||||||
<Text fontSize={0}>
|
<Text fontSize={0}>
|
||||||
<Markdown>{param.description}</Markdown>
|
<Markdown>{param.description}</Markdown>
|
||||||
</Text>
|
</Text>
|
||||||
{param.anyOf && param.anyOf.map(schema => <Expand schema={schema} />)}
|
{param.anyOf &&
|
||||||
{param.oneOf && param.oneOf.map(schema => <Expand schema={schema} />)}
|
param.anyOf.map(schema => <Expand schema={schema} spec={spec} />)}
|
||||||
|
{param.oneOf &&
|
||||||
|
param.oneOf.map(schema => <Expand schema={schema} spec={spec} />)}
|
||||||
{param.type === "array" && param.items?.properties && (
|
{param.type === "array" && param.items?.properties && (
|
||||||
<Expand schema={param.items} />
|
<Expand schema={param.items} spec={spec} />
|
||||||
)}
|
)}
|
||||||
</Box>
|
</Box>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,19 +1,27 @@
|
|||||||
import React from "react"
|
import React from "react"
|
||||||
import { Flex, Box, Text } from "rebass"
|
import { Box, Text } from "rebass"
|
||||||
|
|
||||||
import ParamSection from "./param-section"
|
import ParamSection from "./param-section"
|
||||||
|
|
||||||
const Parameters = ({ endpoint }) => {
|
import { deref } from "../utils/deref"
|
||||||
|
|
||||||
|
const Parameters = ({ endpoint, spec }) => {
|
||||||
const aggregated = endpoint.parameters || []
|
const aggregated = endpoint.parameters || []
|
||||||
|
|
||||||
const reqBody = endpoint.requestBody || {}
|
const reqBody = endpoint.requestBody || {}
|
||||||
const props = reqBody.content?.["application/json"]?.schema?.properties
|
const props = reqBody.content?.["application/json"]?.schema?.properties
|
||||||
if (props) {
|
if (props) {
|
||||||
for (const [name, details] of Object.entries(props)) {
|
for (const [name, details] of Object.entries(props)) {
|
||||||
|
let cleanDets = details
|
||||||
|
if (name === "$ref") {
|
||||||
|
const [, ...path] = details.split("/")
|
||||||
|
cleanDets = deref(path, spec)
|
||||||
|
}
|
||||||
|
|
||||||
if (!aggregated.find(a => a.name === name)) {
|
if (!aggregated.find(a => a.name === name)) {
|
||||||
aggregated.push({
|
aggregated.push({
|
||||||
name,
|
name,
|
||||||
...details,
|
...cleanDets,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -32,7 +40,7 @@ const Parameters = ({ endpoint }) => {
|
|||||||
>
|
>
|
||||||
<Text my={2}>Parameters</Text>
|
<Text my={2}>Parameters</Text>
|
||||||
{aggregated.map(p => (
|
{aggregated.map(p => (
|
||||||
<ParamSection param={p} />
|
<ParamSection param={p} spec={spec} />
|
||||||
))}
|
))}
|
||||||
</Box>
|
</Box>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import React from "react"
|
|||||||
import { Flex, Box, Text } from "rebass"
|
import { Flex, Box, Text } from "rebass"
|
||||||
|
|
||||||
const RouteSection = ({ basePath, path, method }) => {
|
const RouteSection = ({ basePath, path, method }) => {
|
||||||
path = path.replaceAll(/{(.*?)}/g, ":$1")
|
path = path.replace(/{(.*?)}/g, ":$1")
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box py={2}>
|
<Box py={2}>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import React, { useState, useEffect } from "react"
|
import React from "react"
|
||||||
import styled from "@emotion/styled"
|
import styled from "@emotion/styled"
|
||||||
import { Flex, Box, Text, Image } from "rebass"
|
import { Flex, Box, Text } from "rebass"
|
||||||
|
|
||||||
const StyledRoutesOverview = styled(Flex)`
|
const StyledRoutesOverview = styled(Flex)`
|
||||||
border: 1px solid #e3e8ee;
|
border: 1px solid #e3e8ee;
|
||||||
@@ -51,7 +51,7 @@ const RoutesOverview = ({ content }) => {
|
|||||||
{route.method}
|
{route.method}
|
||||||
</Text>
|
</Text>
|
||||||
<Text color="#4f566b">
|
<Text color="#4f566b">
|
||||||
{route.path?.replaceAll(/{(.*?)}/g, ":$1")}
|
{route.path?.replace(/{(.*?)}/g, ":$1")}
|
||||||
</Text>
|
</Text>
|
||||||
</Flex>
|
</Flex>
|
||||||
))}
|
))}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import React, { useState, useEffect } from "react"
|
import React, { useState, useEffect } from "react"
|
||||||
import { Link, navigate } from "gatsby"
|
import { navigate } from "gatsby"
|
||||||
import { Flex, Box, Text } from "rebass"
|
import { Flex, Box, Text } from "rebass"
|
||||||
import { AnchorLink } from "gatsby-plugin-anchor-links"
|
import { AnchorLink } from "gatsby-plugin-anchor-links"
|
||||||
import styled from "@emotion/styled"
|
import styled from "@emotion/styled"
|
||||||
@@ -63,11 +63,6 @@ const SideBarContainer = styled(Flex)`
|
|||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
`
|
`
|
||||||
|
|
||||||
const StyledLink = styled(Link)`
|
|
||||||
color: #212121;
|
|
||||||
font-decoration: none;
|
|
||||||
`
|
|
||||||
|
|
||||||
const SideBar = ({ tags }) => {
|
const SideBar = ({ tags }) => {
|
||||||
const [api, setApi] = useState("store")
|
const [api, setApi] = useState("store")
|
||||||
|
|
||||||
@@ -89,7 +84,6 @@ const SideBar = ({ tags }) => {
|
|||||||
px={4}
|
px={4}
|
||||||
py={3}
|
py={3}
|
||||||
mb={3}
|
mb={3}
|
||||||
justifyContent="center"
|
|
||||||
flexDirection="column"
|
flexDirection="column"
|
||||||
>
|
>
|
||||||
<Flex width={"100%"} alignContent="center">
|
<Flex width={"100%"} alignContent="center">
|
||||||
|
|||||||
+29
-38
@@ -1,47 +1,38 @@
|
|||||||
import React, { useState, useEffect } from "react"
|
|
||||||
|
|
||||||
const useSpec = raw => {
|
const useSpec = raw => {
|
||||||
const [tags, setTags] = useState({})
|
let tags = {}
|
||||||
const [spec, setSpec] = useState({})
|
|
||||||
|
|
||||||
useEffect(() => {
|
for (const [path, methods] of Object.entries(raw.paths)) {
|
||||||
setSpec(raw)
|
for (const [method, specification] of Object.entries(methods)) {
|
||||||
|
for (const t of specification.tags) {
|
||||||
for (const [path, methods] of Object.entries(raw.paths)) {
|
if (t in tags) {
|
||||||
for (const [method, specification] of Object.entries(methods)) {
|
tags = {
|
||||||
for (const t of specification.tags) {
|
...tags,
|
||||||
setTags(ts => {
|
[t]: [
|
||||||
if (t in ts) {
|
...tags[t],
|
||||||
return {
|
{
|
||||||
...ts,
|
method: method.toUpperCase(),
|
||||||
[t]: [
|
path,
|
||||||
...ts[t],
|
...specification,
|
||||||
{
|
},
|
||||||
method: method.toUpperCase(),
|
],
|
||||||
path,
|
}
|
||||||
...specification,
|
} else {
|
||||||
},
|
tags = {
|
||||||
],
|
...tags,
|
||||||
}
|
[t]: [
|
||||||
} else {
|
{
|
||||||
return {
|
method: method.toUpperCase(),
|
||||||
...ts,
|
path,
|
||||||
[t]: [
|
...specification,
|
||||||
{
|
},
|
||||||
method: method.toUpperCase(),
|
],
|
||||||
path,
|
}
|
||||||
...specification,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, [])
|
}
|
||||||
|
|
||||||
return { tags, spec }
|
return { tags, spec: raw }
|
||||||
}
|
}
|
||||||
|
|
||||||
export default useSpec
|
export default useSpec
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import React, { useState, useEffect } from "react"
|
import React from "react"
|
||||||
import { Flex } from "rebass"
|
import { Flex } from "rebass"
|
||||||
import { Helmet } from "react-helmet"
|
import { Helmet } from "react-helmet"
|
||||||
|
|
||||||
|
|||||||
+6
-27
@@ -1,38 +1,17 @@
|
|||||||
import React, { useState, useEffect } from "react"
|
import React from "react"
|
||||||
import { Flex } from "rebass"
|
import { Flex } from "rebass"
|
||||||
import { Helmet } from "react-helmet"
|
import { Helmet } from "react-helmet"
|
||||||
|
|
||||||
import adminSpec from "../../../docs/api/admin-spec3.json"
|
import rawSpec from "../../../docs/api/admin-spec3.json"
|
||||||
import spec from "../../../docs/api/admin-spec3.json"
|
|
||||||
|
|
||||||
import Layout from "../components/layout"
|
import Layout from "../components/layout"
|
||||||
import SideBar from "../components/sidebar"
|
import SideBar from "../components/sidebar"
|
||||||
import DocsReader from "../components/docs-reader"
|
import DocsReader from "../components/docs-reader"
|
||||||
|
|
||||||
export default function Home() {
|
import useSpec from "../hooks/use-spec"
|
||||||
const tags = {}
|
|
||||||
|
|
||||||
for (const [path, methods] of Object.entries(spec.paths)) {
|
export default function Home() {
|
||||||
for (const [method, specification] of Object.entries(methods)) {
|
const { tags, spec } = useSpec(rawSpec)
|
||||||
for (const t of specification.tags) {
|
|
||||||
if (t in tags) {
|
|
||||||
tags[t].push({
|
|
||||||
method: method.toUpperCase(),
|
|
||||||
path,
|
|
||||||
...specification,
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
tags[t] = [
|
|
||||||
{
|
|
||||||
method: method.toUpperCase(),
|
|
||||||
path,
|
|
||||||
...specification,
|
|
||||||
},
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Layout>
|
<Layout>
|
||||||
@@ -41,7 +20,7 @@ export default function Home() {
|
|||||||
</Helmet>
|
</Helmet>
|
||||||
<Flex>
|
<Flex>
|
||||||
<SideBar tags={tags} />
|
<SideBar tags={tags} />
|
||||||
<DocsReader tags={tags} />
|
<DocsReader tags={tags} spec={spec} />
|
||||||
</Flex>
|
</Flex>
|
||||||
</Layout>
|
</Layout>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
export const deref = (path, spec) => {
|
||||||
|
let cleanDets = spec
|
||||||
|
for (const part of path) {
|
||||||
|
if (part === "#") continue
|
||||||
|
cleanDets = cleanDets[part]
|
||||||
|
}
|
||||||
|
|
||||||
|
return cleanDets
|
||||||
|
}
|
||||||
@@ -1002,6 +1002,13 @@
|
|||||||
dependencies:
|
dependencies:
|
||||||
regenerator-runtime "^0.13.4"
|
regenerator-runtime "^0.13.4"
|
||||||
|
|
||||||
|
"@babel/runtime@^7.12.5":
|
||||||
|
version "7.13.10"
|
||||||
|
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.13.10.tgz#47d42a57b6095f4468da440388fdbad8bebf0d7d"
|
||||||
|
integrity sha512-4QPkjJq6Ns3V/RgpEahRk+AGfL0eO6RHHtTWoNNr5mO49G6B5+X6d6THgWEAvTrznU5xYpbAlVKRYcsCgh/Akw==
|
||||||
|
dependencies:
|
||||||
|
regenerator-runtime "^0.13.4"
|
||||||
|
|
||||||
"@babel/standalone@^7.11.6":
|
"@babel/standalone@^7.11.6":
|
||||||
version "7.11.6"
|
version "7.11.6"
|
||||||
resolved "https://registry.yarnpkg.com/@babel/standalone/-/standalone-7.11.6.tgz#2ea3c9463c8b1d04ee2dacc5ac4b81674cec2967"
|
resolved "https://registry.yarnpkg.com/@babel/standalone/-/standalone-7.11.6.tgz#2ea3c9463c8b1d04ee2dacc5ac4b81674cec2967"
|
||||||
@@ -5961,6 +5968,14 @@ gatsby-telemetry@^1.3.36:
|
|||||||
node-fetch "^2.6.0"
|
node-fetch "^2.6.0"
|
||||||
uuid "3.4.0"
|
uuid "3.4.0"
|
||||||
|
|
||||||
|
gatsby-transformer-json@^3.0.0:
|
||||||
|
version "3.0.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/gatsby-transformer-json/-/gatsby-transformer-json-3.0.0.tgz#e8ab61ac5aa9aa7699c00d869c63b91ce37d606e"
|
||||||
|
integrity sha512-MyQZdoGbr1OEtFkAF1BAEvfhZKZVeD00yCX/9E/CSd/73jrBqxXqSWN2gIVx9HlPRbPUjmChMW6Nwx0z6GF+MA==
|
||||||
|
dependencies:
|
||||||
|
"@babel/runtime" "^7.12.5"
|
||||||
|
bluebird "^3.7.2"
|
||||||
|
|
||||||
gatsby-transformer-yaml@^2.4.13:
|
gatsby-transformer-yaml@^2.4.13:
|
||||||
version "2.4.13"
|
version "2.4.13"
|
||||||
resolved "https://registry.yarnpkg.com/gatsby-transformer-yaml/-/gatsby-transformer-yaml-2.4.13.tgz#791e8bed84b91161af5ac2b1368855fd68830158"
|
resolved "https://registry.yarnpkg.com/gatsby-transformer-yaml/-/gatsby-transformer-yaml-2.4.13.tgz#791e8bed84b91161af5ac2b1368855fd68830158"
|
||||||
|
|||||||
Reference in New Issue
Block a user