Skip to content

Commit a671816

Browse files
Hide example title for autogenerated AMF names (#13)
* test(demo): add steve test * feat: hide example title if it matches media type + a number * chore(deps): regenerate package-lock.json * doc: add documentation for new methods * 4.3.0 * chore: remove multiple unnecessary files
1 parent d3df89a commit a671816

12 files changed

+1857
-1013
lines changed

demo/apis.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22
"demo-api/demo-api.raml": "RAML 1.0",
33
"raml-types/raml-types.raml": "RAML 1.0",
44
"google-drive-api/google-drive-api.raml": "RAML 1.0",
5-
"oas-3-api/oas-3-api.yaml": { "type": "OAS 3.0", "mime": "application/yaml" }
5+
"oas-3-api/oas-3-api.yaml": { "type": "OAS 3.0", "mime": "application/yaml" },
6+
"steveTest-1/stevetest.json": { "type": "OAS 2.0", "mime": "application/json" }
67
}

demo/index.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ class ApiDemo extends ApiDemoPage {
4646
this.payloads = this.hasData ? payloads : undefined;
4747
if (this.hasData) {
4848
setTimeout(() => {
49+
// eslint-disable-next-line no-shadow
4950
const list = document.body.querySelector('#mediaList');
5051
if (list) {
5152
list.selected = 0;
@@ -69,6 +70,7 @@ class ApiDemo extends ApiDemoPage {
6970
if (!(payloads instanceof Array)) {
7071
payloads = [payloads];
7172
}
73+
// eslint-disable-next-line consistent-return
7274
return payloads;
7375
}
7476

@@ -83,13 +85,14 @@ class ApiDemo extends ApiDemoPage {
8385
result.push({label});
8486
}
8587
});
88+
// eslint-disable-next-line consistent-return
8689
return result.length ? result : undefined;
8790
}
8891

8992
_mediaChanged(e) {
9093
this.hasExamples = false;
9194
const index = e.detail.value;
92-
if (isNaN(index) || index === -1) {
95+
if (Number.isNaN(index) || index === -1) {
9396
return;
9497
}
9598
const mediaType = this.mediaTypes[index].label;
@@ -103,6 +106,7 @@ class ApiDemo extends ApiDemoPage {
103106
const result = [];
104107

105108
[
109+
['stevetest', 'Stevetest'],
106110
['demo-api', 'Demo API'],
107111
['google-drive-api', 'Google Drive'],
108112
['raml-types', 'RAML types with raml examples'],
@@ -115,7 +119,7 @@ class ApiDemo extends ApiDemoPage {
115119
}
116120

117121
_examplesTemplate() {
118-
const hasExamples = this.hasExamples;
122+
const {hasExamples} = this;
119123
return hasExamples ?
120124
html`<api-resource-example-document
121125
.amf="${this.amf}"
@@ -125,8 +129,8 @@ class ApiDemo extends ApiDemoPage {
125129
}
126130

127131
contentTemplate() {
128-
const mediaTypes = this.mediaTypes;
129-
const hasData = this.hasData;
132+
const {mediaTypes} = this;
133+
const {hasData} = this;
130134
return html`
131135
<anypoint-dropdown-menu ?hidden="${this.singlePayload}">
132136
<label slot="label">Select media type</label>
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-04/schema",
3+
"id": "http://example.com/example.json",
4+
"type": "object",
5+
"required": [
6+
"logonID",
7+
"site",
8+
"siteRole",
9+
"acceptedDate"
10+
],
11+
"properties": {
12+
"logonID": {
13+
"id": "#/properties/logonID",
14+
"type": "string",
15+
"description": "OneAmerica user's application logonID.",
16+
"example": "indybrad"
17+
},
18+
"site": {
19+
"id": "#/properties/site",
20+
"type": "string",
21+
"description": "OneAmerica web application identifier within which user is accepting terms.",
22+
"example": "ACCTSERV"
23+
},
24+
"siteRole": {
25+
"id": "#/properties/siteRole",
26+
"type": "string",
27+
"description": "OneAmerica user's role within the web application.",
28+
"example": "PARTCPNT"
29+
},
30+
"impersonationID": {
31+
"id": "#/properties/impersonationID",
32+
"type": "string",
33+
"description": "OneAmerica user account that is accepting on behalf of the actual OneAmerica user.",
34+
"example": "xyz123"
35+
},
36+
"acceptedDate": {
37+
"id": "#/properties/acceptedDate",
38+
"type": "string",
39+
"description": "Datetime of acceptance of terms by the OneAmerica user.",
40+
"example": "2018-01-01T12:00:00.000"
41+
}
42+
}
43+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-04/schema",
3+
"id": "http://example.com/example.json",
4+
"type": "object",
5+
"default": {},
6+
"additionalProperties": true,
7+
"properties": {
8+
"logonID": {
9+
"id": "#/properties/logonID",
10+
"type": "string",
11+
"description": "OneAmerica user's application logonID."
12+
},
13+
"accepted": {
14+
"id": "#/properties/accepted",
15+
"type": "boolean",
16+
"description": "True/False indicator on whether legal terms were accepted."
17+
},
18+
"acceptedDate": {
19+
"id": "#/properties/acceptedDate",
20+
"type": "string",
21+
"description": "Date of acceptance of legal terms."
22+
}
23+
}
24+
}

demo/steveTest-1/stevetest.json

Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
{
2+
"swagger": "2.0",
3+
"info": {
4+
"title": "Legal System Service v1",
5+
"description": "This is the suite of Participant Legal services.",
6+
"version": "1.0.0",
7+
"termsOfService": "http://www.oneamerica.com",
8+
"contact": {
9+
"email": "jedimaster@oneamerica.com"
10+
},
11+
"license": {
12+
"name": "OneAmerica 1.0"
13+
}
14+
},
15+
"host": "esb.oneamerica.com:61006",
16+
"basePath": "/api",
17+
"schemes": [
18+
"https"
19+
],
20+
"consumes": [
21+
"application/json"
22+
],
23+
"produces": [
24+
"application/json"
25+
],
26+
"tags": [
27+
{
28+
"name": "test",
29+
"description": "test"
30+
}
31+
],
32+
"parameters": {
33+
"trait:content-type-required:content-type": {
34+
"required": true,
35+
"type": "string",
36+
"in": "header",
37+
"name": "content-type"
38+
}
39+
},
40+
"paths": {
41+
"/legal/termsConditionsAcceptReset": {
42+
"delete": {
43+
"description": "Delete participants existing terms and conditions",
44+
"responses": {
45+
"200": {
46+
"description": "This status code will be returned when request passes"
47+
},
48+
"400": {
49+
"$ref": "traits/response-errors.json#/responses/400"
50+
},
51+
"404": {
52+
"$ref": "traits/response-errors.json#/responses/404"
53+
},
54+
"405": {
55+
"$ref": "traits/response-errors.json#/responses/405"
56+
},
57+
"406": {
58+
"$ref": "traits/response-errors.json#/responses/406"
59+
},
60+
"415": {
61+
"$ref": "traits/response-errors.json#/responses/406"
62+
},
63+
"500": {
64+
"$ref": "traits/response-errors.json#/responses/500"
65+
},
66+
"501": {
67+
"$ref": "traits/response-errors.json#/responses/501"
68+
}
69+
}
70+
}
71+
},
72+
"/legal/termsConditionsAccept": {
73+
"get": {
74+
"description": "Retrieves a user's status on terms and conditions acceptance.",
75+
"responses": {
76+
"200": {
77+
"description": "This status code will be returned when request passes.",
78+
"schema": {
79+
"$ref": "schemas_response/schema-termsConditionsAccept-Get.json"
80+
},
81+
"examples": {
82+
"application/json": {
83+
"logonID": "indybrad",
84+
"accepted" : true,
85+
"acceptedDate" : "2018-01-01T12:00:00.000"
86+
}
87+
}
88+
},
89+
"400": {
90+
"$ref": "traits/response-errors.json#/responses/400"
91+
},
92+
"404": {
93+
"$ref": "traits/response-errors.json#/responses/404"
94+
},
95+
"405": {
96+
"$ref": "traits/response-errors.json#/responses/405"
97+
},
98+
"406": {
99+
"$ref": "traits/response-errors.json#/responses/406"
100+
},
101+
"415": {
102+
"$ref": "traits/response-errors.json#/responses/406"
103+
},
104+
"500": {
105+
"$ref": "traits/response-errors.json#/responses/500"
106+
},
107+
"501": {
108+
"$ref": "traits/response-errors.json#/responses/501"
109+
}
110+
},
111+
"parameters": [
112+
{
113+
"required": true,
114+
"type": "string",
115+
"in": "header",
116+
"name": "webLogonID"
117+
},
118+
{
119+
"$ref": "#/parameters/trait:content-type-required:content-type"
120+
}
121+
]
122+
},
123+
"post": {
124+
"description": "Store participant's terms and conditions acceptance.",
125+
"responses": {
126+
"200": {
127+
"description": "This status code will be returned when request passes."
128+
},
129+
"400": {
130+
"$ref": "traits/response-errors.json#/responses/400"
131+
},
132+
"404": {
133+
"$ref": "traits/response-errors.json#/responses/404"
134+
},
135+
"405": {
136+
"$ref": "traits/response-errors.json#/responses/405"
137+
},
138+
"406": {
139+
"$ref": "traits/response-errors.json#/responses/406"
140+
},
141+
"415": {
142+
"$ref": "traits/response-errors.json#/responses/406"
143+
},
144+
"500": {
145+
"$ref": "traits/response-errors.json#/responses/500"
146+
},
147+
"501": {
148+
"$ref": "traits/response-errors.json#/responses/501"
149+
}
150+
},
151+
"parameters": [
152+
{
153+
"$ref": "#/parameters/trait:content-type-required:content-type"
154+
},
155+
{
156+
"in": "body",
157+
"name": "body",
158+
"schema": {
159+
"$ref": "schemas/schema-termsConditionsAccept.json"
160+
},
161+
"required": true
162+
}
163+
]
164+
}
165+
}
166+
}
167+
}

0 commit comments

Comments
 (0)