-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix: force swr cache invalidation * chore: changeset * fix: reduce the number of calls to the api by tweaking swr revalidate config * chore: try different swr setup * feat: handle json primitive types * feat: render primitive json types * chore: fix broken link * fix: regressionvrt errors * chore: address PR comments * chore: changeset
- Loading branch information
1 parent
8fa2dbc
commit 8759c1e
Showing
9 changed files
with
112 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
'@commercetools-docs/gatsby-theme-api-docs': patch | ||
'@commercetools-website/api-docs-smoke-test': patch | ||
'@commercetools-api-specs/test': patch | ||
--- | ||
|
||
Add support for primitive and generic JSON types in API request and response |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
api-specs/test/examples/json-serializable-primitive-object.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
"raw string" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 27 additions & 11 deletions
38
packages/gatsby-theme-api-docs/src/utils/render-type-as-link.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,36 @@ | ||
import React from 'react'; | ||
import { Link } from '@commercetools-docs/gatsby-theme-docs'; | ||
import { markdownFragmentToReact } from '@commercetools-docs/ui-kit'; | ||
import { markdownFragmentToReact, Markdown } from '@commercetools-docs/ui-kit'; | ||
import { locationForType } from '../hooks/use-type-locations'; | ||
import { getDescriptionIfPrimitiveType } from '../components/type/type'; | ||
|
||
function renderTypeAsLink(apiKey, type, typeLocations, description) { | ||
function renderTypeAsLink( | ||
apiKey, | ||
type, | ||
typeLocations, | ||
description, | ||
contentType | ||
) { | ||
const typeLocation = locationForType(apiKey, type, typeLocations); | ||
|
||
const originalTypeLocation = typeLocation ? typeLocation.url : ''; | ||
const originalTypeLocation = typeLocation ? typeLocation.url : undefined; | ||
|
||
return originalTypeLocation ? ( | ||
<Link href={originalTypeLocation}>{type}</Link> | ||
) : description ? ( | ||
markdownFragmentToReact(description) | ||
) : ( | ||
type | ||
); | ||
} | ||
let primitiveJsonType; | ||
if ( | ||
!originalTypeLocation && | ||
Array.isArray(contentType) && | ||
contentType.includes('application/json') | ||
) { | ||
primitiveJsonType = getDescriptionIfPrimitiveType('application/json', type); | ||
} | ||
|
||
if (originalTypeLocation) { | ||
return <Link href={originalTypeLocation}>{type}</Link>; | ||
} else if (primitiveJsonType) { | ||
return <Markdown.Em>{primitiveJsonType}</Markdown.Em>; | ||
} else if (description) { | ||
return markdownFragmentToReact(description); | ||
} | ||
return type; | ||
} | ||
export default renderTypeAsLink; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters