Skip to content

Commit

Permalink
Parameters had a new line on the timeout that broke the regex for the…
Browse files Browse the repository at this point in the history
… example gen
  • Loading branch information
krowvin committed May 7, 2024
1 parent 2bee043 commit 56e3f28
Show file tree
Hide file tree
Showing 2 changed files with 167 additions and 2 deletions.
165 changes: 165 additions & 0 deletions docs/examples/Parameters.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@



<!DOCTYPE html>
<html class="default" lang="en">

<head>
<meta charSet="utf-8" />
<meta http-equiv="x-ua-compatible" content="IE=edge" />
<title>Parameters Example</title>
<meta name="description" content="Documentation for cwmsjs" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="stylesheet" href="../assets/style.css" />
<link rel="stylesheet" href="../assets/highlight.css" />
<script defer src="../assets/main.js"></script>
<script async src="../assets/icons.js" id="tsd-icons-script"></script>
<script async src="../assets/search.js" id="tsd-search-script"></script>
<script async src="../assets/navigation.js" id="tsd-nav-script"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/prismjs@1.26.0/themes/prism.css" id="light-theme" disabled>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/prismjs@1.26.0/themes/prism-okaidia.css" id="dark-theme">
</head>

<body>
<script>document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os"; document.body.style.display = "none"; setTimeout(() => app ? app.showPage() : document.body.style.removeProperty("display"), 500)</script>
<script>
const lightTheme = document.getElementById('light-theme');
const darkTheme = document.getElementById('dark-theme');
if (document.documentElement.dataset.theme == "light") {
lightTheme.disabled = false;
darkTheme.disabled = true;
} else {
lightTheme.disabled = true;
darkTheme.disabled = false;
}
</script>
<header class="tsd-page-toolbar">
<div class="tsd-toolbar-contents container">
<div class="table-cell" id="tsd-search" data-base="..">
<div class="field"><label for="tsd-search-field"
class="tsd-widget tsd-toolbar-icon search no-caption"><svg width="16" height="16"
viewBox="0 0 16 16" fill="none">
<use href="../assets/icons.svg#icon-search"></use>
</svg></label><input type="text" id="tsd-search-field" aria-label="Search" /></div>
<div class="field">
<div id="tsd-toolbar-links"></div>
</div>
<ul class="results">
<li class="state loading">Preparing search index...</li>
<li class="state failure">The search index is not available</li>
</ul><a href="/cwms-data-api-client-javascript/" class="title">HOME - cwmsjs - v1.12.0</a>
</div>
</div>
</header>
<div class="container container-main">
<div class="col-content">
<div class="tsd-page-title">
<ul class="tsd-breadcrumb">
<li><a href="../modules.html">cwmsjs</a></li>
<li><a href="/cwms-data-api-client-javascript/examples">Examples</a></li>
<li><a href="/cwms-data-api-client-javascript/examples/Parameters.html">Parameters</a></li>
</ul>
<h1>Example: Parameters</h1>
</div>
<section class="tsd-panel tsd-comment">
<div class="tsd-comment tsd-typography">
<p>An example for calling the Parameters endpoint via CDA in JavaScript</p>
<p><a href="https://cwms-data.usace.army.mil/cwms-data">Swagger UI</a> for Endpoints</p>
</div>
<div class="tsd-comment tsd-typography"></div>
</section>
<section class="tsd-panel tsd-hierarchy">

<h2>React + Vite Example</h2>
<b>To Install:</b>
<code class="language-shell">npm install cwmsjs --save</code><br>
<p><em>Download browser bundle.js <a href="https://github.com/HydrologicEngineeringCenter/cwms-data-api-client-javascript/blob/main/src/dist/bundle.js">here</a></em></p>
<pre>
<code class="language-javascript">import { ParametersApi } from "cwmsjs";


const p_api = new ParametersApi()
await p_api.getCwmsDataParametersRaw({
&quot;office&quot;: &quot;SWT&quot;
})
.then(r =&gt; r.raw.json())
.then(data =&gt; {
console.log(data.parameters)
console.log(data?.parameters)
console.log(data?.parameters?.parameters)
Object.entries(data?.parameters?.parameters).forEach(([key, value]) =&gt; {
console.log(value?.[&quot;abstract-param&quot;])
console.log(value?.[&quot;office&quot;])
console.log(value?.[&quot;default-english-unit&quot;])
console.log(value?.[&quot;default-si-unit&quot;])
console.log(value?.[&quot;long-name&quot;])
console.log(value?.[&quot;description&quot;])
});

}).catch(async e =&gt; {
if (e.response) {
const error_msg = await e.response.json()
e.message = `${e.response.url}\n${e.message}\n${JSON.stringify(error_msg, null, 2)}`;
console.error(e);
throw e;
} else {
throw e;
}
})</code>
</pre>
<h2>Bundle / Vanilla JS Example</h2>
<b>To Install:</b><br>
<p>
<ol>
<li>Run <br>
<code class="language-shell">curl -O "https://raw.githubusercontent.com/HydrologicEngineeringCenter/cwms-data-api-client-javascript/main/src/dist/bundle.js"</code><br>
to download bundle.js to your system</li>
<li>Copy bundle.js to your web directory if not in that directory already</li>
</o>
</p>
<pre>
<code class="language-html">&lt;!-- Include the bundle.js file --&gt;
&lt;script src=&quot;./bundle.js&quot;&gt;&lt;/script&gt;
&lt;!-- Call the cwmsjs after the bundle has loaded --&gt;
&lt;script type=&quot;module&quot;&gt;
const p_api = new cwmsjs.ParametersApi()
await p_api.getCwmsDataParametersRaw({
&quot;office&quot;: &quot;SWT&quot;
})
.then(r =&gt; r.raw.json())
.then(data =&gt; {
console.log(data.parameters)
console.log(data?.parameters)
console.log(data?.parameters?.parameters)
Object.entries(data?.parameters?.parameters).forEach(([key, value]) =&gt; {
console.log(value?.[&quot;abstract-param&quot;])
console.log(value?.[&quot;office&quot;])
console.log(value?.[&quot;default-english-unit&quot;])
console.log(value?.[&quot;default-si-unit&quot;])
console.log(value?.[&quot;long-name&quot;])
console.log(value?.[&quot;description&quot;])
});

}).catch(async e =&gt; {
if (e.response) {
const error_msg = await e.response.json()
e.message = `${e.response.url}\n${e.message}\n${JSON.stringify(error_msg, null, 2)}`;
console.error(e);
throw e;
} else {
throw e;
}
})
&lt;/script&gt;</code>
</pre>
</section>
</div>
</div>
<footer>
<p class="tsd-generator">Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p>
</footer>
<div class="overlay"></div>
<script src="https://cdn.jsdelivr.net/npm/prismjs@1.26.0/prism.js"></script>
</body>

</html>
4 changes: 2 additions & 2 deletions tests/endpoints/Parameters.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ test('Test Parameters', async () => {
})
.then(r => r.raw.json())
.then(data => {
console.log(data.parameters)
expect(data?.parameters).toBeDefined()
expect(data?.parameters?.parameters).toBeDefined()
Object.entries(data?.parameters?.parameters).forEach(([key, value]) => {
Expand All @@ -30,5 +31,4 @@ test('Test Parameters', async () => {
throw e;
}
})
}
, 60000)
}, 60000)

0 comments on commit 56e3f28

Please sign in to comment.