Skip to content

Commit 4f36af9

Browse files
Steveb-pMagdalenaZuba
authored andcommitted
Added JSON /views example (#1857)
1 parent 54be0a8 commit 4f36af9

File tree

6 files changed

+69
-8
lines changed

6 files changed

+69
-8
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"ViewInput": {
3+
"identifier": "TitleView",
4+
"Query": {
5+
"Filter": {
6+
"ContentTypeIdentifierCriterion": "image",
7+
"SectionIdentifierCriterion": "media",
8+
"DateMetadataCriterion": {
9+
"Target": "modified",
10+
"Value": 1675681020,
11+
"Operator": "gte"
12+
}
13+
},
14+
"limit": 10,
15+
"offset": 0,
16+
"SortClauses": {
17+
"ContentName": "ascending"
18+
},
19+
"Aggregations": [
20+
{
21+
"ContentTypeTermAggregation": {
22+
"name": "some name"
23+
}
24+
}
25+
]
26+
}
27+
}
28+
}
Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,27 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<ViewInput>
33
<identifier>TitleView</identifier>
4-
<ContentQuery>
4+
<Query>
55
<Filter>
66
<ContentTypeIdentifierCriterion>image</ContentTypeIdentifierCriterion>
77
<SectionIdentifierCriterion>media</SectionIdentifierCriterion>
8+
<DateMetadataCriterion>
9+
<Target>modified</Target>
10+
<Value>1675681020</Value>
11+
<Operator>gte</Operator>
12+
</DateMetadataCriterion>
813
</Filter>
914
<limit>10</limit>
1015
<offset>0</offset>
1116
<SortClauses>
1217
<ContentName>ascending</ContentName>
1318
</SortClauses>
14-
<FacetBuilders>
15-
<contentTypeFacetBuilder/>
16-
</FacetBuilders>
17-
</ContentQuery>
19+
<Aggregations>
20+
<Aggregation>
21+
<ContentTypeTermAggregation>
22+
<name>some name</name>
23+
</ContentTypeTermAggregation>
24+
</Aggregation>
25+
</Aggregations>
26+
</Query>
1827
</ViewInput>

docs/api/rest_api/rest_api_reference/input/ez-views.raml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
displayName: Views
22
post:
33
displayName: Create View
4-
description: Executes a query and returns a View including the results. The View input reflects the criteria model of the public API.
4+
description: |
5+
Executes a query and returns a View including the results.
6+
7+
View input reflects the criteria model of the public API.
8+
9+
Refer to [Search Criteria Reference](/en/latest/search/criteria_reference/search_criteria_reference/)
510
headers:
611
Accept:
712
description: The view in XML or JSON format.
@@ -21,6 +26,9 @@ post:
2126
application/vnd.ibexa.api.ViewInput+xml:
2227
type: ViewInput
2328
example: !include examples/views/POST/ViewInput.xml.example
29+
application/vnd.ibexa.api.ViewInput+json:
30+
type: ViewInput
31+
example: !include examples/views/POST/ViewInput.json.example
2432
responses:
2533
200:
2634
body:

tools/raml2html/composer.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@
2020
"raml-org/raml-php-parser": "dev-master",
2121
"twig/twig": "^2.0",
2222
"symfony/filesystem": "^4.2",
23-
"ramsey/uuid": "^3.9"
23+
"ramsey/uuid": "^3.9",
24+
"twig/markdown-extra": "^3.5",
25+
"league/commonmark": "^2.3"
2426
},
2527
"require-dev": {
2628
"symfony/var-dumper": "^4.2",

tools/raml2html/src/Application.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
use EzSystems\Raml2Html\Twig\Extension\RenderExtension;
1313
use Symfony\Component\Console\Application as BaseApplication;
1414
use Twig as Twig;
15+
use Twig\Extra\Markdown\DefaultMarkdown;
16+
use Twig\Extra\Markdown\MarkdownExtension;
17+
use Twig\Extra\Markdown\MarkdownRuntime;
18+
use Twig\RuntimeLoader\RuntimeLoaderInterface;
1519

1620
final class Application extends BaseApplication
1721
{
@@ -49,6 +53,16 @@ public function getTwig(): Twig\Environment
4953

5054
$this->twig = new Twig\Environment($loader, $options);
5155
$this->twig->addExtension(new RenderExtension());
56+
$this->twig->addExtension(new MarkdownExtension());
57+
$this->twig->addRuntimeLoader(new class implements RuntimeLoaderInterface {
58+
public function load($class): ?MarkdownRuntime {
59+
if (MarkdownRuntime::class === $class) {
60+
return new MarkdownRuntime(new DefaultMarkdown());
61+
}
62+
63+
return null;
64+
}
65+
});
5266
}
5367

5468
return $this->twig;

tools/raml2html/themes/default/resource.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<span data-field="method" class="badge badge--sm badge--{{ method.type|lower }}">{{ method.type }}</span>
1616
<span data-field="url">{{ resource.uri }}</span>
1717
</p>
18-
<p data-field="body">{{ method.description }}</p>
18+
<p data-field="body">{{ method.description|default('')|markdown_to_html }}</p>
1919
{% include theme ~ "/method-headers.html.twig" %}
2020

2121
{% include theme ~ "/method-query-parameters.html.twig" %}

0 commit comments

Comments
 (0)