Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pull and extract Go and Java examples #7446

Merged
merged 19 commits into from
May 27, 2020
Merged
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Include required query arguments in curl examples
  • Loading branch information
jirikuncar committed May 13, 2020
commit c7f8c7f1b909a0f80e5c85531f1242712166de5c
16 changes: 15 additions & 1 deletion layouts/api/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -406,17 +406,31 @@ <h3 class="mb-2">Code Example</h3>
<button class="btn text-primary js-copy-button">Copy</button>
</div>
{{ $pathParams := $.Scratch.Get "pathParams" }}
{{ $queryStrings := $.Scratch.Get "queryStrings" }}
<div class="highlight">
<pre class="chroma">
{{/* Do not change indent of html below as it will change the indentation of the curl code block */}}
<code class="language-fallback" data-lang="fallback">
{{- with $pathParams -}}
{{- range . -}}
<span class="kn">export</span> <span class="n">{{ .name }}</span><span class="o">=</span><span class="s1">"{{ .example | default "CHANGE_ME"}}"</span>
<span class="kn">export</span> <span class="n">{{ .name }}</span><span class="o">=</span><span class="s1">"{{ .example | default (.schema.example | default "CHANGE_ME") }}"</span>
{{- end }}
{{ end -}}

{{- with $queryStrings -}}
{{- range . -}}
{{- if eq .required true -}}
<span class="kn">export</span> <span class="n">{{ .name }}</span><span class="o">=</span><span class="s1">"{{ .example | default (.schema.example | default "CHANGE_ME") }}"</span>
{{- end -}}
{{- end }}
{{ end -}}

<span class="n">curl</span> <span class="o">-X</span> <span class="s1 text-uppercase">{{ $context.actionType }}</span> {{ range $.Scratch.Get "serverURLS" }}<span class="kn d-none" data-region="{{ .region }}">{{ .url }}</span>{{ end }}<span class="n">{{ replace $context.pathKey "{" "${" }}</span>
{{- range $i, $q := $queryStrings -}}
{{- if eq .required true -}}
<span class="o">{{ cond (eq $i 0) "?" "&" }}</span><span class="n">{{ $q.name }}</span><span class="o">=</span><span class="s1">${ {{- $q.name -}} }</span>
{{- end -}}
{{- end -}}

{{- /* Render authentication query parameters "?api_key=XXX" */ -}}
{{- $i := 0 -}}
Expand Down