Skip to content
This repository has been archived by the owner on Nov 28, 2022. It is now read-only.

Commit

Permalink
fix: issues preventing people from upgrading off our legacy explorer (#…
Browse files Browse the repository at this point in the history
…602)

* chore: updating deps in the lockfile

* fix: always attempt to uppercase language names

* fix: stop double-nesting json response examples

* fix: bug where legacy responses that weren't set up are ignored

* chore(deps): upgrading @readme/api-explorer to 3.1.9

* fix: always try to render an operations path

* docs: Update packages/api-explorer/src/lib/upgrade-legacy-responses.js

Co-Authored-By: Rafe Goldberg <rafegoldberg@gmail.com>

Co-authored-by: Rafe Goldberg <rafegoldberg@gmail.com>
  • Loading branch information
erunion and rafegoldberg authored Apr 15, 2020
1 parent 2da7a88 commit 4385347
Show file tree
Hide file tree
Showing 9 changed files with 49 additions and 73 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ function encodeJsonExample(json) {
}

describe('upgradeLegacyResponses', () => {
it('should not return anything for an legacy response that hasnt been fully configured', () => {
expect(upgradeLegacyResponses([{ language: 'text', code: '' }])).toStrictEqual([]);
});

it('should return codes array for a legacy response shape', () => {
const encodedExample = {
meta: {
Expand Down
52 changes: 26 additions & 26 deletions packages/api-explorer/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 8 additions & 11 deletions packages/api-explorer/src/PathUrl.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,17 +81,14 @@ function PathUrl({
)}

<span className={`pg-type-big pg-type type-${operation.method}`}>{operation.method}</span>

{oas.servers && oas.servers.length > 0 && (
<span className="definition-url">
<span className="url">{oas.url()}</span>
{splitPath(operation.path).map(part => (
<span key={part.key} className={`api-${part.type}`}>
{part.value}
</span>
))}
</span>
)}
<span className="definition-url">
<span className="url">{oas.url()}</span>
{splitPath(operation.path).map(part => (
<span key={part.key} className={`api-${part.type}`}>
{part.value}
</span>
))}
</span>
</div>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion packages/api-explorer/src/ResponseExample.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ class ResponseExample extends React.Component {
)}

{isJson && !example.multipleExamples ? (
<div className="example example_json">{transformExampleIntoReactJson(example)}</div>
transformExampleIntoReactJson(example)
) : (
// json + multiple examples is already handled in `showExamples`.
<React.Fragment>
Expand Down
2 changes: 1 addition & 1 deletion packages/api-explorer/src/lib/generate-code-snippet.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,4 @@ module.exports = (oas, operation, values, auth, lang) => {
};
};

module.exports.getLangName = lang => (supportedLanguages[lang] ? uppercase(lang) : lang);
module.exports.getLangName = lang => uppercase(lang);
5 changes: 5 additions & 0 deletions packages/api-explorer/src/lib/upgrade-legacy-responses.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ module.exports = responses => {
const codes = {};

responses.forEach(response => {
// If there's no status set, then the legacy response wasn't fully configured so we should ignore it.
if (!('status' in response)) {
return;
}

if (typeof codes[response.status] === 'undefined') {
codes[response.status] = {
languages: {},
Expand Down
30 changes: 0 additions & 30 deletions packages/markdown-magic/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions packages/oas-to-har/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/oas-to-har/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"main": "src/index.js",
"dependencies": {
"@readme/oas-extensions": "^6.0.5",
"@readme/oas-tooling": "^3.1.8",
"@readme/oas-tooling": "^3.1.9",
"querystring": "^0.2.0"
},
"scripts": {
Expand Down

0 comments on commit 4385347

Please sign in to comment.