Skip to content

Commit ee47530

Browse files
committed
New: Adding support for compact model
1 parent d3919ea commit ee47530

14 files changed

+1046
-548
lines changed

api-documentation-document.html

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
<link rel="import" href="../polymer/lib/elements/dom-if.html">
33
<link rel="import" href="../marked-element/marked-element.html">
44
<link rel="import" href="../markdown-styles/markdown-styles.html">
5+
<link rel="import" href="../amf-helper-mixin/amf-helper-mixin.html">
56
<dom-module id="api-documentation-document">
67
<template>
78
<style include="markdown-styles"></style>
@@ -43,9 +44,10 @@ <h1>[[title]]</h1>
4344
* @polymer
4445
* @demo demo/index.html
4546
* @memberof ApiElements
47+
* @appliesMixin ApiElements.AmfHelperMixin
4648
*/
47-
class ApiDocumentationDocument extends Polymer.Element {
48-
static get is() { return 'api-documentation-document'; }
49+
class ApiDocumentationDocument extends ApiElements.AmfHelperMixin(Polymer.Element) {
50+
static get is() {return 'api-documentation-document';}
4951
static get properties() {
5052
return {
5153
/**
@@ -60,7 +62,7 @@ <h1>[[title]]</h1>
6062
*/
6163
title: {
6264
type: String,
63-
computed: '_computeTitle(apiDocument)'
65+
computed: '_computeTitle(apiDocument, amfModel)'
6466
},
6567
/**
6668
* Computed value, true if `title` is set.
@@ -74,7 +76,7 @@ <h1>[[title]]</h1>
7476
*/
7577
content: {
7678
type: String,
77-
computed: '_computeContent(apiDocument)'
79+
computed: '_computeContent(apiDocument, amfModel)'
7880
}
7981
};
8082
}
@@ -85,8 +87,7 @@ <h1>[[title]]</h1>
8587
* @return {String|undefined}
8688
*/
8789
_computeTitle(doc) {
88-
const data = doc && doc['http://schema.org/title'];
89-
return data ? data[0]['@value'] : undefined;
90+
return this._getValue(doc, this.ns.schema.title);
9091
}
9192
/**
9293
* Computes value for `hasTitle` property
@@ -104,8 +105,7 @@ <h1>[[title]]</h1>
104105
* @return {String|undefined}
105106
*/
106107
_computeContent(doc) {
107-
const data = doc && doc['http://schema.org/description'];
108-
return data ? data[0]['@value'] : undefined;
108+
return this._getValue(doc, this.ns.schema.desc);
109109
}
110110
}
111111
window.customElements.define(ApiDocumentationDocument.is, ApiDocumentationDocument);

bower.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,21 @@
1414
"dependencies": {
1515
"polymer": "Polymer/polymer#^2.0.0",
1616
"marked-element": "PolymerElements/marked-element#^2.4.0",
17-
"markdown-styles": "advanced-rest-client/markdown-styles#^2.0.2"
17+
"markdown-styles": "advanced-rest-client/markdown-styles#^2.0.2",
18+
"amf-helper-mixin": "advanced-rest-client/amf-helper-mixin#^2.0.0"
1819
},
1920
"devDependencies": {
2021
"iron-demo-helpers": "PolymerElements/iron-demo-helpers#^2.0.0",
2122
"iron-component-page": "PolymerElements/iron-component-page#^3.0.1",
2223
"iron-test-helpers": "PolymerElements/iron-test-helpers#^2.0.0",
2324
"web-component-tester": "Polymer/web-component-tester#^6.0.0",
2425
"webcomponentsjs": "webcomponents/webcomponentsjs#^1.0.0",
25-
"api-navigation": "advanced-rest-client/api-navigation#^2.0.0"
26+
"api-navigation": "advanced-rest-client/api-navigation#^2.0.0",
27+
"paper-dropdown-menu": "PolymerElements/paper-dropdown-menu#^2.0.3",
28+
"paper-listbox": "PolymerElements/paper-listbox#^2.0.0",
29+
"paper-item": "PolymerElements/paper-item#^2.1.0",
30+
"web-animations-js": "web-animations/web-animations-js#^2.3",
31+
"api-console-default-theme": "advanced-rest-client/api-console-default-theme#5.0.0-preview"
2632
},
2733
"repository": {
2834
"type": "git",

demo/demo-api-compact.json

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
{
2+
"@context": {
3+
"raml-http": "http://a.ml/vocabularies/http#",
4+
"shacl": "http://www.w3.org/ns/shacl#",
5+
"raml-shapes": "http://a.ml/vocabularies/shapes#",
6+
"security": "http://a.ml/vocabularies/security#",
7+
"rdfs": "http://www.w3.org/2000/01/rdf-schema#",
8+
"data": "http://a.ml/vocabularies/data#",
9+
"doc": "http://a.ml/vocabularies/document#",
10+
"schema-org": "http://schema.org/",
11+
"xsd": "http://www.w3.org/2001/XMLSchema#",
12+
"hydra": "http://www.w3.org/ns/hydra/core#"
13+
},
14+
"@id": "amf://id",
15+
"@type": [
16+
"doc:Document",
17+
"doc:Fragment",
18+
"doc:Module",
19+
"doc:Unit"
20+
],
21+
"doc:encodes": {
22+
"@id": "amf://id#4",
23+
"@type": [
24+
"schema-org:WebAPI",
25+
"doc:RootDomainElement",
26+
"doc:DomainElement"
27+
],
28+
"raml-http:server": {
29+
"@id": "amf://id#5",
30+
"@type": [
31+
"raml-http:Server",
32+
"doc:DomainElement"
33+
],
34+
"raml-http:url": "http://api.domain.com/"
35+
},
36+
"schema-org:documentation": [
37+
{
38+
"@id": "amf://id#6",
39+
"@type": [
40+
"schema-org:CreativeWork",
41+
"doc:DomainElement"
42+
],
43+
"schema-org:description": "# This is an example API spec\nThe API doesn't exists in the real world therefore calls made to any endpoint will always fail.\nIf you'd like to perform actual request and see the response try GitHub API (which doesn't require user authentication in some endpoints) or other APIs.\nNote that you may need a Client ID or valid authorization token to perform a call to some APIs that are secured by the OAuth 2 protocol.\nThank you for testing the API console. Your feedback is welcome. Email us: arc@mulesoft.com\n",
44+
"schema-org:title": "Read this!"
45+
},
46+
{
47+
"@id": "amf://id#2",
48+
"@type": [
49+
"schema-org:CreativeWork",
50+
"doc:DomainElement"
51+
],
52+
"schema-org:description": "This is test document.\n\n## Example\nLet's say you want to generate a random number in the request. So the property\nvalue like:\n```\nhttp://www.domain.com/?time=${now}\n```\ncan produce:\n```\nhttp://www.domain.com/?time=12312312312\n```\n## Build-in magic variables.\n| Variable | Description | Example |\n| --- | --- | --- |\n| `${random}` | Will generate random number in range from 0 to Number.MAX_SAFE_INTEGER | 9007199254740991 |\n| `${random:NUMBER}` | A variation of `${random}` where the result will be remembered and can be used in other property. If the same `NUMBER` occurs again then previously generated value will be used. | 7199254740 |\n| `${now}` | Inserts current epoch time | 12312312312 |\n",
53+
"schema-org:title": "About"
54+
},
55+
{
56+
"@id": "amf://id#7",
57+
"@type": [
58+
"schema-org:CreativeWork",
59+
"doc:DomainElement"
60+
],
61+
"schema-org:description": "# A test documentation.\nThis text was created by ARC's RAML editor.\nYou probably see this because you are testing ARC's web components and this component\nis responsible for displaying a documentation from the RAML definition.\nPlay around with the element and use it in your project.\nPlease, note the licensing information available in every ARC component.\nIf you have any question email me: arc@mulesoft.com\nOr slack me (internally only): Pawel Psztyc (P3)\n",
62+
"schema-org:title": "Test docs"
63+
}
64+
],
65+
"schema-org:name": "My super cool, example API",
66+
"schema-org:version": "v1"
67+
},
68+
"doc:references": {
69+
"@id": "amf://id#1",
70+
"@type": [
71+
"doc:UserDocumentation",
72+
"doc:Fragment",
73+
"doc:Unit"
74+
],
75+
"doc:encodes": {
76+
"@id": "amf://id#2",
77+
"@type": [
78+
"schema-org:CreativeWork",
79+
"doc:DomainElement"
80+
],
81+
"schema-org:description": "This is test document.\n\n## Example\nLet's say you want to generate a random number in the request. So the property\nvalue like:\n```\nhttp://www.domain.com/?time=${now}\n```\ncan produce:\n```\nhttp://www.domain.com/?time=12312312312\n```\n## Build-in magic variables.\n| Variable | Description | Example |\n| --- | --- | --- |\n| `${random}` | Will generate random number in range from 0 to Number.MAX_SAFE_INTEGER | 9007199254740991 |\n| `${random:NUMBER}` | A variation of `${random}` where the result will be remembered and can be used in other property. If the same `NUMBER` occurs again then previously generated value will be used. | 7199254740 |\n| `${now}` | Inserts current epoch time | 12312312312 |\n",
82+
"schema-org:title": "About"
83+
}
84+
}
85+
}

demo/api.json renamed to demo/demo-api.json

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,33 @@
11
[
22
{
3-
"@id": "file://demo/api.raml",
3+
"@id": "amf://id",
44
"@type": [
5-
"http://raml.org/vocabularies/document#Document",
6-
"http://raml.org/vocabularies/document#Fragment",
7-
"http://raml.org/vocabularies/document#Module",
8-
"http://raml.org/vocabularies/document#Unit"
5+
"http://a.ml/vocabularies/document#Document",
6+
"http://a.ml/vocabularies/document#Fragment",
7+
"http://a.ml/vocabularies/document#Module",
8+
"http://a.ml/vocabularies/document#Unit"
99
],
10-
"http://raml.org/vocabularies/document#encodes": [
10+
"http://a.ml/vocabularies/document#encodes": [
1111
{
12-
"@id": "file://demo/api.raml#/web-api",
12+
"@id": "amf://id#4",
1313
"@type": [
1414
"http://schema.org/WebAPI",
15-
"http://raml.org/vocabularies/document#RootDomainElement",
16-
"http://raml.org/vocabularies/document#DomainElement"
15+
"http://a.ml/vocabularies/document#RootDomainElement",
16+
"http://a.ml/vocabularies/document#DomainElement"
1717
],
1818
"http://schema.org/name": [
1919
{
2020
"@value": "My super cool, example API"
2121
}
2222
],
23-
"http://raml.org/vocabularies/http#server": [
23+
"http://a.ml/vocabularies/http#server": [
2424
{
25-
"@id": "file://demo/api.raml#/web-api/http%3A%2F%2Fapi.domain.com%2F",
25+
"@id": "amf://id#5",
2626
"@type": [
27-
"http://raml.org/vocabularies/http#Server",
28-
"http://raml.org/vocabularies/document#DomainElement"
27+
"http://a.ml/vocabularies/http#Server",
28+
"http://a.ml/vocabularies/document#DomainElement"
2929
],
30-
"http://raml.org/vocabularies/http#url": [
30+
"http://a.ml/vocabularies/http#url": [
3131
{
3232
"@value": "http://api.domain.com/"
3333
}
@@ -41,10 +41,10 @@
4141
],
4242
"http://schema.org/documentation": [
4343
{
44-
"@id": "file://demo/api.raml#/web-api/creative-work/Read%20this!",
44+
"@id": "amf://id#6",
4545
"@type": [
4646
"http://schema.org/CreativeWork",
47-
"http://raml.org/vocabularies/document#DomainElement"
47+
"http://a.ml/vocabularies/document#DomainElement"
4848
],
4949
"http://schema.org/title": [
5050
{
@@ -58,10 +58,10 @@
5858
]
5959
},
6060
{
61-
"@id": "file://demo/document.raml/creative-work/About",
61+
"@id": "amf://id#2",
6262
"@type": [
6363
"http://schema.org/CreativeWork",
64-
"http://raml.org/vocabularies/document#DomainElement"
64+
"http://a.ml/vocabularies/document#DomainElement"
6565
],
6666
"http://schema.org/title": [
6767
{
@@ -75,10 +75,10 @@
7575
]
7676
},
7777
{
78-
"@id": "file://demo/api.raml#/web-api/creative-work/Test%20docs",
78+
"@id": "amf://id#7",
7979
"@type": [
8080
"http://schema.org/CreativeWork",
81-
"http://raml.org/vocabularies/document#DomainElement"
81+
"http://a.ml/vocabularies/document#DomainElement"
8282
],
8383
"http://schema.org/title": [
8484
{
@@ -94,20 +94,20 @@
9494
]
9595
}
9696
],
97-
"http://raml.org/vocabularies/document#references": [
97+
"http://a.ml/vocabularies/document#references": [
9898
{
99-
"@id": "file://demo/document.raml",
99+
"@id": "amf://id#1",
100100
"@type": [
101-
"http://raml.org/vocabularies/document#UserDocumentation",
102-
"http://raml.org/vocabularies/document#Fragment",
103-
"http://raml.org/vocabularies/document#Unit"
101+
"http://a.ml/vocabularies/document#UserDocumentation",
102+
"http://a.ml/vocabularies/document#Fragment",
103+
"http://a.ml/vocabularies/document#Unit"
104104
],
105-
"http://raml.org/vocabularies/document#encodes": [
105+
"http://a.ml/vocabularies/document#encodes": [
106106
{
107-
"@id": "file://demo/document.raml/creative-work/About",
107+
"@id": "amf://id#2",
108108
"@type": [
109109
"http://schema.org/CreativeWork",
110-
"http://raml.org/vocabularies/document#DomainElement"
110+
"http://a.ml/vocabularies/document#DomainElement"
111111
],
112112
"http://schema.org/title": [
113113
{

demo/api.raml renamed to demo/demo-api/demo-api.raml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ documentation:
1111
If you'd like to perform actual request and see the response try GitHub API (which doesn't require user authentication in some endpoints) or other APIs.
1212
Note that you may need a Client ID or valid authorization token to perform a call to some APIs that are secured by the OAuth 2 protocol.
1313
Thank you for testing the API console. Your feedback is welcome. Email us: arc@mulesoft.com
14-
- !include document.raml
14+
- !include ../demo-document/demo-document.raml
1515
- title: Test docs
1616
content: |
1717
# A test documentation.

demo/demo-document-compact.json

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"@context": {
3+
"raml-http": "http://a.ml/vocabularies/http#",
4+
"shacl": "http://www.w3.org/ns/shacl#",
5+
"raml-shapes": "http://a.ml/vocabularies/shapes#",
6+
"security": "http://a.ml/vocabularies/security#",
7+
"rdfs": "http://www.w3.org/2000/01/rdf-schema#",
8+
"data": "http://a.ml/vocabularies/data#",
9+
"doc": "http://a.ml/vocabularies/document#",
10+
"schema-org": "http://schema.org/",
11+
"xsd": "http://www.w3.org/2001/XMLSchema#",
12+
"hydra": "http://www.w3.org/ns/hydra/core#"
13+
},
14+
"@id": "amf://id",
15+
"@type": [
16+
"doc:UserDocumentation",
17+
"doc:Fragment",
18+
"doc:Unit"
19+
],
20+
"doc:encodes": {
21+
"@id": "amf://id#1",
22+
"@type": [
23+
"schema-org:CreativeWork",
24+
"doc:DomainElement"
25+
],
26+
"schema-org:description": "This is test document.\n\n## Example\nLet's say you want to generate a random number in the request. So the property\nvalue like:\n```\nhttp://www.domain.com/?time=${now}\n```\ncan produce:\n```\nhttp://www.domain.com/?time=12312312312\n```\n## Build-in magic variables.\n| Variable | Description | Example |\n| --- | --- | --- |\n| `${random}` | Will generate random number in range from 0 to Number.MAX_SAFE_INTEGER | 9007199254740991 |\n| `${random:NUMBER}` | A variation of `${random}` where the result will be remembered and can be used in other property. If the same `NUMBER` occurs again then previously generated value will be used. | 7199254740 |\n| `${now}` | Inserts current epoch time | 12312312312 |\n",
27+
"schema-org:title": "About"
28+
}
29+
}

demo/document.json renamed to demo/demo-document.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
[
22
{
3-
"@id": "file://demo/document.raml",
3+
"@id": "amf://id",
44
"@type": [
5-
"http://raml.org/vocabularies/document#UserDocumentation",
6-
"http://raml.org/vocabularies/document#Fragment",
7-
"http://raml.org/vocabularies/document#Unit"
5+
"http://a.ml/vocabularies/document#UserDocumentation",
6+
"http://a.ml/vocabularies/document#Fragment",
7+
"http://a.ml/vocabularies/document#Unit"
88
],
9-
"http://raml.org/vocabularies/document#encodes": [
9+
"http://a.ml/vocabularies/document#encodes": [
1010
{
11-
"@id": "file://demo/document.raml/creative-work/About",
11+
"@id": "amf://id#1",
1212
"@type": [
1313
"http://schema.org/CreativeWork",
14-
"http://raml.org/vocabularies/document#DomainElement"
14+
"http://a.ml/vocabularies/document#DomainElement"
1515
],
1616
"http://schema.org/title": [
1717
{
File renamed without changes.

0 commit comments

Comments
 (0)