Skip to content

Commit a50a197

Browse files
authored
Merge pull request #234 from os2display/release/2.2.0
Release 2.2.0
2 parents decf097 + 1b95378 commit a50a197

File tree

146 files changed

+6576
-4104
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

146 files changed

+6576
-4104
lines changed

.env

+11
Original file line numberDiff line numberDiff line change
@@ -92,3 +92,14 @@ REDIS_CACHE_PREFIX=DisplayApiService
9292
REDIS_CACHE_DSN=redis://redis:6379/0
9393
###< redis ###
9494

95+
###> Calendar Api Feed Source ###
96+
# See docs/calendar-api-feed.md for variable explainations.
97+
CALENDAR_API_FEED_SOURCE_LOCATION_ENDPOINT=
98+
CALENDAR_API_FEED_SOURCE_RESOURCE_ENDPOINT=
99+
CALENDAR_API_FEED_SOURCE_EVENT_ENDPOINT=
100+
CALENDAR_API_FEED_SOURCE_CUSTOM_MAPPINGS='{}'
101+
CALENDAR_API_FEED_SOURCE_EVENT_MODIFIERS='{}'
102+
CALENDAR_API_FEED_SOURCE_DATE_FORMAT=
103+
CALENDAR_API_FEED_SOURCE_DATE_TIMEZONE=
104+
CALENDAR_API_FEED_SOURCE_CACHE_EXPIRE_SECONDS=300
105+
###< Calendar Api Feed Source ###

CHANGELOG.md

+16
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,22 @@ All notable changes to this project will be documented in this file.
44

55
## [Unreleased]
66

7+
## [2.2.0] - 2025-03-17
8+
9+
- [#229](https://github.com/os2display/display-api-service/pull/229)
10+
- Adds options to set paths to component and admin files from path to the json config file.
11+
- [#225](https://github.com/os2display/display-api-service/pull/225)
12+
- Added ADRs.
13+
- [#215](https://github.com/os2display/display-api-service/pull/215)
14+
- Added calendar api feed type.
15+
- [#223](https://github.com/os2display/display-api-service/pull/223)
16+
- Added explicit fixtures to avoid false negatives in the test suite
17+
- [#219](https://github.com/os2display/display-api-service/pull/219)
18+
- Fixed psalm, test, coding standards and updated api spec.
19+
- [#222](https://github.com/os2display/display-api-service/pull/222)
20+
- Adds create, update, delete operations to feed-source endpoint.
21+
- Adds data validation for feed source.
22+
723
## [2.1.4] - 2025-01-14
824

925
- [#230](https://github.com/os2display/display-api-service/pull/230)

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,9 @@
128128
],
129129
"prepare-code": [
130130
"bin/console doctrine:schema:validate",
131+
"@coding-standards-apply",
131132
"vendor/bin/rector",
132133
"vendor/bin/psalm --no-cache",
133-
"@coding-standards-apply",
134134
"@test-setup",
135135
"@test"
136136
],

config/api_platform/feed_source.yaml

+108-25
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@ resources:
55
output: App\Dto\FeedSource
66
provider: App\State\FeedSourceProvider
77
processor: App\State\FeedSourceProcessor
8-
98
operations:
10-
ApiPlatform\Metadata\Get: &get
9+
ApiPlatform\Metadata\Get: &ref_0
1110
normalizationContext:
1211
jsonld_embed_context: true
1312
openapiContext:
@@ -20,7 +19,7 @@ resources:
2019
- schema:
2120
type: string
2221
format: ulid
23-
pattern: "^[A-Za-z0-9]{26}$"
22+
pattern: '^[A-Za-z0-9]{26}$'
2423
name: id
2524
in: path
2625
required: true
@@ -29,14 +28,12 @@ resources:
2928
description: OK
3029
content:
3130
application/ld+json:
32-
examples:
31+
examples: null
3332
headers: {}
34-
35-
# https://api-platform.com/docs/core/controllers/
3633
_api_Feed_get_source_config:
3734
class: ApiPlatform\Metadata\Get
3835
method: GET
39-
uriTemplate: '/feed_sources/{id}/config/{name}'
36+
uriTemplate: '/feed-sources/{id}/config/{name}'
4037
read: false
4138
controller: App\Controller\FeedSourceConfigGetController
4239
openapiContext:
@@ -49,13 +46,13 @@ resources:
4946
- schema:
5047
type: string
5148
format: ulid
52-
pattern: "^[A-Za-z0-9]{26}$"
49+
pattern: '^[A-Za-z0-9]{26}$'
5350
name: id
5451
in: path
5552
required: true
5653
- schema:
5754
type: string
58-
pattern: "^[A-Za-z0-9]*$"
55+
pattern: '^[A-Za-z0-9]*$'
5956
name: name
6057
in: path
6158
required: true
@@ -66,17 +63,18 @@ resources:
6663
examples:
6764
example1:
6865
value:
69-
- {key: 'key1', id: 'id1', value: 'value1'}
66+
- key: key1
67+
id: id1
68+
value: value1
7069
headers: {}
71-
7270
ApiPlatform\Metadata\GetCollection:
7371
filters:
74-
- 'entity.search_filter'
75-
- 'entity.blameable_filter'
76-
- 'entity.order_filter'
77-
- 'created.at.order_filter'
78-
- 'modified.at.order_filter'
79-
- 'feed_source.search_filter'
72+
- entity.search_filter
73+
- entity.blameable_filter
74+
- entity.order_filter
75+
- created.at.order_filter
76+
- modified.at.order_filter
77+
- feed_source.search_filter
8078
openapiContext:
8179
operationId: get-v2-feed-sources
8280
description: Retrieves a collection of FeedSource resources.
@@ -99,23 +97,108 @@ resources:
9997
description: The number of items per page
10098
- schema:
10199
type: string
102-
pattern: "^[A-Za-z0-9]*$"
100+
pattern: '^[A-Za-z0-9]*$'
103101
name: supportedFeedOutputType
104102
in: query
103+
responses:
104+
'200':
105+
description: OK
106+
content:
107+
application/ld+json:
108+
examples: null
109+
headers: {}
110+
ApiPlatform\Metadata\Put:
111+
security: is_granted("ROLE_ADMIN")
112+
openapiContext:
113+
description: Update a Feed Source resource.
114+
summary: Update a Feed Source resource.
115+
operationId: put-v2-feed-source-id
116+
tags:
117+
- FeedSources
118+
parameters:
119+
- schema:
120+
type: string
121+
format: ulid
122+
pattern: '^[A-Za-z0-9]{26}$'
123+
name: id
124+
in: path
125+
required: true
126+
ApiPlatform\Metadata\Delete:
127+
security: is_granted("ROLE_ADMIN")
128+
openapiContext:
129+
description: Delete a Feed Source resource.
130+
summary: Delete a Feed Source resource.
131+
operationId: delete-v2-feed-source-id
132+
tags:
133+
- FeedSources
134+
parameters:
135+
- schema:
136+
type: string
137+
format: ulid
138+
pattern: '^[A-Za-z0-9]{26}$'
139+
name: id
140+
in: path
105141
required: true
142+
ApiPlatform\Metadata\Post:
143+
security: is_granted("ROLE_ADMIN")
144+
openapiContext:
145+
operationId: create-v2-feed-source
146+
description: Creates a Feed Source resource.
147+
summary: Creates a Feed Source resource.
148+
tags:
149+
- FeedSources
150+
'_api_/feed_sources/{id}/slides_get': &ref_1
151+
normalizationContext:
152+
groups:
153+
- 'playlist-slide:read'
154+
class: ApiPlatform\Metadata\GetCollection
155+
method: GET
156+
provider: App\State\FeedSourceSlideProvider
157+
filters:
158+
- entity.search_filter
159+
- entity.blameable_filter
160+
- App\Filter\PublishedFilter
161+
- entity.order_filter
162+
- created.at.order_filter
163+
- modified.at.order_filter
164+
uriTemplate: '/feed-sources/{id}/slides'
165+
openapiContext:
166+
description: Retrieves collection of weighted slide resources (feedsource).
167+
summary: Retrieves collection of weighted slide resources (feedsource).
168+
operationId: get-v2-feed-source-slide-id
169+
tags:
170+
- FeedSources
171+
parameters:
172+
- schema:
173+
type: string
174+
format: ulid
175+
pattern: '^[A-Za-z0-9]{26}$'
176+
name: id
177+
in: path
178+
required: true
179+
- schema:
180+
type: integer
181+
minimum: 0
182+
format: int32
183+
default: 1
184+
in: query
185+
name: page
186+
required: true
187+
- schema:
188+
type: string
189+
default: '10'
190+
in: query
191+
name: itemsPerPage
192+
description: The number of items per page
106193
responses:
107194
'200':
108195
description: OK
109196
content:
110197
application/ld+json:
111-
examples:
198+
examples: null
112199
headers: {}
113-
114-
# Our DTO must be a resource to get a proper URL
115-
# @see https://stackoverflow.com/a/75705084
116-
# @see https://github.com/api-platform/core/issues/5451
117200
App\Dto\FeedSource:
118201
provider: App\State\FeedSourceProvider
119-
120202
operations:
121-
ApiPlatform\Metadata\Get: *get
203+
ApiPlatform\Metadata\Get: *ref_0
204+
get_slides: *ref_1

config/packages/cache.yaml

+5-1
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,17 @@ framework:
1717
# Default expire set to 5 minutes
1818
default_lifetime: 300
1919

20+
# Creates a "calendar.api.cache" service
21+
calendar.api.cache:
22+
adapter: cache.adapter.redis
23+
2024
# Creates a "auth.screen.cache" service
2125
auth.screen.cache:
2226
adapter: cache.adapter.redis
2327
# Default expire set to 1 day
2428
default_lifetime: 86400
2529

26-
# Creates a "interactive_slide.cache" service
30+
# Creates an "interactive_slide.cache" service
2731
interactive_slide.cache:
2832
adapter: cache.adapter.redis
2933
# Default expire set to 12 hours

config/services.yaml

+16
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,17 @@ services:
5151
Symfony\Component\Security\Http\Authentication\AuthenticationFailureHandlerInterface: '@Lexik\Bundle\JWTAuthenticationBundle\Security\Http\Authentication\AuthenticationFailureHandler'
5252
Symfony\Component\Security\Http\Authentication\AuthenticationSuccessHandlerInterface: '@Lexik\Bundle\JWTAuthenticationBundle\Security\Http\Authentication\AuthenticationSuccessHandler'
5353

54+
App\Feed\CalendarApiFeedType:
55+
arguments:
56+
$locationEndpoint: '%env(string:CALENDAR_API_FEED_SOURCE_LOCATION_ENDPOINT)%'
57+
$resourceEndpoint: '%env(string:CALENDAR_API_FEED_SOURCE_RESOURCE_ENDPOINT)%'
58+
$eventEndpoint: '%env(string:CALENDAR_API_FEED_SOURCE_EVENT_ENDPOINT)%'
59+
$customMappings: '%env(json:CALENDAR_API_FEED_SOURCE_CUSTOM_MAPPINGS)%'
60+
$eventModifiers: '%env(json:CALENDAR_API_FEED_SOURCE_EVENT_MODIFIERS)%'
61+
$dateFormat: '%env(string:CALENDAR_API_FEED_SOURCE_DATE_FORMAT)%'
62+
$timezone: '%env(string:CALENDAR_API_FEED_SOURCE_DATE_TIMEZONE)%'
63+
$cacheExpireSeconds: '%env(int:CALENDAR_API_FEED_SOURCE_CACHE_EXPIRE_SECONDS)%'
64+
5465
App\Service\KeyVaultService:
5566
arguments:
5667
$keyVaultSource: '%env(string:APP_KEY_VAULT_SOURCE)%'
@@ -204,6 +215,11 @@ services:
204215
arguments:
205216
$collectionExtensions: !tagged_iterator api_platform.doctrine.orm.query_extension.collection
206217

218+
App\State\FeedSourceSlideProvider:
219+
tags: [ { name: 'api_platform.state_provider', priority: 2 } ]
220+
arguments:
221+
$collectionExtensions: !tagged_iterator api_platform.doctrine.orm.query_extension.collection
222+
207223
App\State\FeedProvider:
208224
tags: [ { name: 'api_platform.state_provider', priority: 2 } ]
209225
arguments:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# ADR 001 - Record architectural decisions
2+
3+
Date: 26-11-2024
4+
5+
## Status
6+
7+
Accepted
8+
9+
## Context
10+
11+
We need to record the architectural decisions made on this project. Architectural Decision Records as
12+
[described by Michael Nygard](https://cognitect.com/blog/2011/11/15/documenting-architecture-decisions) provides a
13+
framework for writing down these decisions.
14+
15+
The project has been running for several years and there is a need for summarizing some of the baselines of the project,
16+
to document the original ideas and decisions.
17+
18+
## Decision
19+
20+
We will use Architectural Decision Records.
21+
22+
We will write down the original architectural decisions as ADRs even though years have passed, to help document the
23+
thoughts behind the project.
24+
25+
## Consequences
26+
27+
This introduces an additional burden on core project maintainers to diligently follow architecture discussions and
28+
record the decisions in this repo as an ADR.

docs/adr/002-api-first.md

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# ADR 002 - API first
2+
3+
Date: 26-11-2024
4+
5+
## Status
6+
7+
Accepted
8+
9+
Written years after the decision was made.
10+
11+
## Context
12+
13+
The "API first" approach is to enforce that all interactions with the system must go through the API.
14+
See more about the "API first" approach [here](https://swagger.io/resources/articles/adopting-an-api-first-approach/).
15+
16+
The previous version of OS2Display was used without the admin module in some contexts.
17+
We want to support other uses than the standard OS2Display setup.
18+
19+
By adopting the API first approach it will be possible to replace or write other clients without rewriting the entire
20+
application. E.g. an external system could create content through calls to the API.
21+
This will make the system more future-proof.
22+
23+
[OpenAPI](https://www.openapis.org/) is a standard for describing an API interface.
24+
25+
## Decision
26+
27+
We will use an API first approach where the only way to get and manage content is through calls to the API.
28+
The API specification will be included [with the project](../../public/api-spec-v2.json) and kept up to date.
29+
We will to develop the clients (admin and screen) separately from the API project to enforce the "API first" approach.
30+
31+
## Consequences
32+
33+
The main consequence is that all interactions with data in the system should be implemented in the API.
34+
This can in some cases be more work, but will give the benefit that the interaction can be used in new contexts later
35+
on.
36+
37+
By supplying an OpenAPI specification clients will be able to auto-generate code for interacting with the API.
38+
This will make it easier to write clients for the system.
39+
40+
By adopting the "API first" approach the API specification will be the contract between the API and clients.
41+
This will limit the extensibility of the project, since the client and API need to be aligned on the interface
42+
between them (the API specification).

docs/adr/003-api-versioning.md

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# ADR 003 - API versioning
2+
3+
Date: 26-11-2024
4+
5+
## Status
6+
7+
Accepted
8+
9+
Written years after the decision was made.
10+
11+
## Context
12+
13+
By versioning the API we can communicate changes in the API. If an endpoint changes in a way that breaks backwards
14+
compatibility we will change the route version. An example of a backwards compatibility break is changing field names.
15+
16+
E.g. changing the field "name" to "title" will be breaking backwards compatibility.
17+
On the other hand, adding the "title" field without removing the "name" field and updating "name" when "title" is
18+
changed will not be a breaking change.
19+
20+
## Decision
21+
22+
We will version our API routes when we break backwards compatibility.
23+
Routes will be prefixed by version: `/v1`, `/v2`...
24+
25+
We will aim at avoiding breaking backwards compatibility as much as possible.
26+
27+
## Consequences
28+
29+
By versioning the API we will communicate changes in the API in a clear way.
30+
This will make it easier to maintain clients communicating with the API.

0 commit comments

Comments
 (0)