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

Commit

Permalink
feat: addition of a new "node-simple" client language for our api sdk…
Browse files Browse the repository at this point in the history
… module (#792)

* chore(deps): pulling in our new httpsnippet client for the api module

* docs: moving the petstore example to be an openapi 3 definition

* chore(deps): upgrading @readme/oas-tooling and httpsnippet-client-api

* fix: content types are now added as a postData mimetype when present

* test: updating some fake test data so it's clearer what it is

* feat: addition of a new `node-simple` language for our api sdk

* test: adding unit tests for the new node-simple client lang

* fix: fixing a bad variable name
  • Loading branch information
erunion authored Jun 16, 2020
1 parent 584af21 commit 8f53c87
Show file tree
Hide file tree
Showing 18 changed files with 1,270 additions and 891 deletions.
6 changes: 6 additions & 0 deletions example/bundle-hub2.css
Original file line number Diff line number Diff line change
Expand Up @@ -9874,6 +9874,12 @@ body.page-password footer,
.is-lang-node #hub-reference .hub-api .code-sample .hub-lang-switch-node {
color: #fff;
}
.is-lang-node-simple #hub-reference .hub-api .code-sample .hub-lang-node-simple {
display: block;
}
.is-lang-node-simple #hub-reference .hub-api .code-sample .hub-lang-switch-node-simple {
color: #fff;
}
.is-lang-objectivec #hub-reference .hub-api .code-sample .hub-lang-objectivec {
display: block;
}
Expand Down
8 changes: 6 additions & 2 deletions example/src/Demo.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,15 @@ class Demo extends React.Component {
}

render() {
const { fetchSwagger, status, docs, oas, oauth } = this.props;
const { fetchSwagger, status, docs, oas, oasUrl, oauth } = this.props;
const { brokenExplorerState, maskErrorMessages, useNewMarkdownEngine } = this.state;

const additionalProps = {
oasFiles: {
'api-setting': Object.assign(extensions.defaults, oas),
'demo-api-setting': Object.assign(extensions.defaults, oas),
},
oasUrls: {
'demo-api-setting': oasUrl,
},
};

Expand Down Expand Up @@ -139,6 +142,7 @@ Demo.propTypes = {
docs: PropTypes.arrayOf(PropTypes.shape).isRequired,
fetchSwagger: PropTypes.func.isRequired,
oas: PropTypes.shape({}).isRequired,
oasUrl: PropTypes.string.isRequired,
oauth: PropTypes.bool,
status: PropTypes.arrayOf(PropTypes.string).isRequired,
};
Expand Down
18 changes: 14 additions & 4 deletions example/src/SpecFetcher.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ function withSpecFetching(Component) {
failure: null,
isLoading: false,
oas: {},
oasUrl: '',
status: [],
};

Expand Down Expand Up @@ -60,17 +61,26 @@ function withSpecFetching(Component) {

return JSON.parse(copy);
})
.then(json => this.dereference(json))
.then(json => {
return this.dereference(json, url);
})
.catch(e => {
this.setState({ isLoading: false });
this.updateStatus(`There was an error handling your API definition:\n\n${e.message}`);
});
});
}

dereference(oas) {
dereference(oas, url) {
let oasUrl = url;
if (url.indexOf('http') < 0) {
// Ensure that our fixtures from example/swagger-files have a publically addressible URL when they're placed
// inside code snippets.
oasUrl = `${window.location.origin}/${url}`;
}

this.createDocs(oas);
this.setState({ oas });
this.setState({ oas, oasUrl });
this.updateStatus('Done!', () => {
setTimeout(() => {
this.setState({ isLoading: false, status: [] });
Expand All @@ -91,7 +101,7 @@ function withSpecFetching(Component) {
}

createDocs(oas) {
this.setState({ docs: createDocs(oas, 'api-setting') });
this.setState({ docs: createDocs(oas, 'demo-api-setting') });
}

render() {
Expand Down
Loading

0 comments on commit 8f53c87

Please sign in to comment.