Skip to content

Commit c13fcf7

Browse files
authored
Merge pull request #75 from github/repo-sync
repo sync
2 parents e647e4f + 42fda8e commit c13fcf7

File tree

4 files changed

+159
-521
lines changed

4 files changed

+159
-521
lines changed

includes/rest_operation.html

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,39 @@ <h4 id="{{operation.slug}}--parameters">
2121
</tr>
2222
</thead>
2323
<tbody>
24-
{% for param in operation.parameters %}
25-
<tr>
26-
<td><code>{{ param.name }}</code></td>
27-
<td class="opacity-70">{{ param.schema.type }}</td>
28-
<td class="opacity-70">{{ param.in }}</td>
29-
<td class="opacity-70">
30-
{{ param.descriptionHTML }}
31-
{% if param.name == 'accept' and param.in == 'header' and operation.x-github.previews.size > 0 %}
24+
<!--
25+
Previews require an `accept` header. These used to be documented
26+
as `operation.parameters` but have moved to `operation.x-github.previews`
27+
-->
28+
<tr>
29+
<td><code>accept</code></td>
30+
<td class="opacity-70">string</td>
31+
<td class="opacity-70">header</td>
32+
<td class="opacity-70">
33+
<p>
34+
{% if operation.hasRequiredPreviews %}
35+
This API is under preview and subject to change.
36+
{% else %}
37+
Setting to <code>application/vnd.github.v3+json</code> is recommended.
38+
{% endif %}
39+
{% if operation.x-github.previews.size > 0 %}
3240
<a href="#{{operation.slug}}-preview-notices">
3341
{% if operation.x-github.previews.size > 1 %}
34-
{{ site.data.ui.products.rest.reference.see_preview_notices }}.
42+
{{ site.data.ui.products.rest.reference.see_preview_notices }}
3543
{% else %}
36-
{{ site.data.ui.products.rest.reference.see_preview_notice }}.
44+
{{ site.data.ui.products.rest.reference.see_preview_notice }}
3745
{% endif %}
3846
</a>
3947
{% endif %}
40-
</td>
48+
</p>
49+
</td>
50+
</tr>
51+
{% for param in operation.parameters %}
52+
<tr>
53+
<td><code>{{ param.name }}</code></td>
54+
<td class="opacity-70">{{ param.schema.type }}</td>
55+
<td class="opacity-70">{{ param.in }}</td>
56+
<td class="opacity-70">{{ param.descriptionHTML }}</td>
4157
</tr>
4258
{% endfor %}
4359
{% for bodyParam in operation.bodyParameters %}

lib/rest.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const { chain, union, flatten, groupBy } = require('lodash')
1+
const { chain, get, union, flatten, groupBy } = require('lodash')
22
const { supported } = require('./enterprise-server-releases')
33
const operations = require('@github/rest-api-operations')
44
// TODO need to update this to the new versions in coordination with openAPI
@@ -16,6 +16,13 @@ const dotcomCategories = getCategories(operations.dotcom)
1616
const enterpriseCategories = flatten(supported.map(v => getCategories(operations[v])))
1717
const categories = union(dotcomCategories, enterpriseCategories)
1818

19+
// Attach convenience properties to each operation that can't easily be created in Liquid
20+
allVersions.forEach(currentVersion => {
21+
operations[currentVersion].forEach(operation => {
22+
operation.hasRequiredPreviews = get(operation, 'x-github.previews', []).some(preview => preview.required)
23+
})
24+
})
25+
1926
// This is a collection of operations that have `enabledForApps = true`
2027
// It's grouped by resource title to make rendering easier
2128
const operationsEnabledForApps = allVersions.reduce((acc, currentVersion) => {

0 commit comments

Comments
 (0)