Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2829: Feed source operations and data validation #222

Draft
wants to merge 47 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
2af5a9b
Refactored feedSourceProcessor to reflect existing state processors
jeppekroghitk Oct 28, 2024
c62756b
Added post, put, delete config to feed source config
jeppekroghitk Oct 28, 2024
0b41ea3
Added tests for FeedSource in FeedSourceTest
jeppekroghitk Oct 28, 2024
2dbff5d
Updated variable names and assertions in FeedSourceTest
jeppekroghitk Oct 28, 2024
980ee63
Linted yaml
jeppekroghitk Oct 28, 2024
10202f3
Corrected yaml formatting
jeppekroghitk Oct 29, 2024
cdffb96
Improved feed source unit test
jeppekroghitk Oct 29, 2024
6ea48d9
Added feed source object validation logic
jeppekroghitk Nov 4, 2024
92c0936
Refactored FeedSourceProcessor: moved URL validation patterns to clas…
jeppekroghitk Nov 4, 2024
e0cb0a5
Added types to constants PATTERN_WITHOUT_PROTOCOL and PATTERN_WITH_PR…
jeppekroghitk Nov 4, 2024
693f1af
format yaml
jeppekroghitk Nov 5, 2024
d8045d0
Updated changelog
jeppekroghitk Nov 5, 2024
4f530e0
Correctly formatted markdown
jeppekroghitk Nov 5, 2024
119e12f
Added feed source slide provider
jeppekroghitk Nov 7, 2024
bde434d
Update feed_source.yaml with new GET methods and resource descriptions
jeppekroghitk Nov 7, 2024
a1ce000
Register FeedSourceSlideProvider in services
jeppekroghitk Nov 7, 2024
c0ea466
Add method to get feed source slide relations by feed source id in Fe…
jeppekroghitk Nov 7, 2024
ad12ecc
Validate 'supportedFeedOutputType' in the 'FeedSourceProcessor' and m…
jeppekroghitk Nov 7, 2024
245bcc8
Update test cases to reflect changes in 'Feed Source'
jeppekroghitk Nov 7, 2024
34ae449
Added a check to serve a more user friendly error if a feed source ca…
jeppekroghitk Nov 7, 2024
6f069c5
Adjusted the process method to call the parent process method outside…
jeppekroghitk Nov 7, 2024
22e341f
Removed discontinued feed type
jeppekroghitk Nov 11, 2024
776595d
Added getSchema method for FeedSource entity
jeppekroghitk Nov 11, 2024
07b22bc
Adjusted constructor, refactored validateFeedSource method and added …
jeppekroghitk Nov 11, 2024
fac8be1
Added getSchema method in NotifiedFeedType class
jeppekroghitk Nov 11, 2024
48e7ed1
Added getSchema method in RssFeedType class
jeppekroghitk Nov 11, 2024
43611d6
Refactored validateFeedSource method in FeedSourceProcessor class
jeppekroghitk Nov 11, 2024
86a7485
Changed getSchema function from static to non-static in EventDatabase…
jeppekroghitk Nov 12, 2024
9a5e842
Added getSchema method declaration in FeedTypeInterface.
jeppekroghitk Nov 12, 2024
9990b3b
Added dynamic getSchema method in KobaFeedType class.
jeppekroghitk Nov 12, 2024
e5a259e
Changed getSchema function from static to non-static in NotifiedFeedT…
jeppekroghitk Nov 12, 2024
d8421f5
Changed getSchema function from static to non-static in RssFeedType.
jeppekroghitk Nov 12, 2024
cc27bde
Added dynamic getSchema method in SparkleIOFeedType class.
jeppekroghitk Nov 12, 2024
cb1af88
Refactored FeedSourceProcessor with updated validations and schema pr…
jeppekroghitk Nov 12, 2024
a77e2aa
Updated api spec
jeppekroghitk Nov 12, 2024
cab2f20
Coding standards
jeppekroghitk Nov 12, 2024
d169294
Yaml lint
jeppekroghitk Nov 12, 2024
1f6d291
Coding standards
jeppekroghitk Nov 12, 2024
aef0260
Change json_decode from object to associative array
jeppekroghitk Nov 12, 2024
6ebb2ef
Change return type of process() and refactor some conditions and methods
jeppekroghitk Nov 12, 2024
44612a6
Update test scenarios due to recent code changes
jeppekroghitk Nov 12, 2024
23e15af
Changed json_decode from object to associative array on the rest of t…
jeppekroghitk Nov 12, 2024
19fc0be
Coding standards
jeppekroghitk Nov 12, 2024
44ee001
Modified getSchema implementation to return PHP array directly
jeppekroghitk Nov 14, 2024
920a267
modified constructor properties
jeppekroghitk Nov 14, 2024
90f9757
Coding standards
jeppekroghitk Nov 14, 2024
936bb02
Cast feed source schema as object for addSchema method
jeppekroghitk Nov 14, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ All notable changes to this project will be documented in this file.
- [#219](https://github.com/os2display/display-api-service/pull/219)
- Fixed psalm, test, coding standards and updated api spec.

- [#222](https://github.com/os2display/display-api-service/pull/222)
- Adds create, update, delete operations to feed-source endpoint.
- Adds data validation for feed source.

## [2.1.3] - 2024-10-25

- [#220](https://github.com/os2display/display-api-service/pull/220)
Expand Down
131 changes: 107 additions & 24 deletions config/api_platform/feed_source.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ resources:
output: App\Dto\FeedSource
provider: App\State\FeedSourceProvider
processor: App\State\FeedSourceProcessor

operations:
ApiPlatform\Metadata\Get: &get
ApiPlatform\Metadata\Get: &ref_0
normalizationContext:
jsonld_embed_context: true
openapiContext:
Expand All @@ -20,7 +19,7 @@ resources:
- schema:
type: string
format: ulid
pattern: "^[A-Za-z0-9]{26}$"
pattern: '^[A-Za-z0-9]{26}$'
name: id
in: path
required: true
Expand All @@ -29,10 +28,8 @@ resources:
description: OK
content:
application/ld+json:
examples:
examples: null
headers: {}

# https://api-platform.com/docs/core/controllers/
_api_Feed_get_source_config:
class: ApiPlatform\Metadata\Get
method: GET
Expand All @@ -49,13 +46,13 @@ resources:
- schema:
type: string
format: ulid
pattern: "^[A-Za-z0-9]{26}$"
pattern: '^[A-Za-z0-9]{26}$'
name: id
in: path
required: true
- schema:
type: string
pattern: "^[A-Za-z0-9]*$"
pattern: '^[A-Za-z0-9]*$'
name: name
in: path
required: true
Expand All @@ -66,17 +63,18 @@ resources:
examples:
example1:
value:
- {key: 'key1', id: 'id1', value: 'value1'}
- key: key1
id: id1
value: value1
headers: {}

ApiPlatform\Metadata\GetCollection:
filters:
- 'entity.search_filter'
- 'entity.blameable_filter'
- 'entity.order_filter'
- 'created.at.order_filter'
- 'modified.at.order_filter'
- 'feed_source.search_filter'
- entity.search_filter
- entity.blameable_filter
- entity.order_filter
- created.at.order_filter
- modified.at.order_filter
- feed_source.search_filter
openapiContext:
operationId: get-v2-feed-sources
description: Retrieves a collection of FeedSource resources.
Expand All @@ -99,23 +97,108 @@ resources:
description: The number of items per page
- schema:
type: string
pattern: "^[A-Za-z0-9]*$"
pattern: '^[A-Za-z0-9]*$'
name: supportedFeedOutputType
in: query
responses:
'200':
description: OK
content:
application/ld+json:
examples: null
headers: {}
ApiPlatform\Metadata\Put:
security: is_granted("ROLE_ADMIN")
openapiContext:
description: Update a Feed Source resource.
summary: Update a Feed Source resource.
operationId: put-v2-feed-source-id
tags:
- FeedSources
parameters:
- schema:
type: string
format: ulid
pattern: '^[A-Za-z0-9]{26}$'
name: id
in: path
required: true
ApiPlatform\Metadata\Delete:
security: is_granted("ROLE_ADMIN")
openapiContext:
description: Delete a Feed Source resource.
summary: Delete a Feed Source resource.
operationId: delete-v2-feed-source-id
tags:
- FeedSources
parameters:
- schema:
type: string
format: ulid
pattern: '^[A-Za-z0-9]{26}$'
name: id
in: path
required: true
ApiPlatform\Metadata\Post:
security: is_granted("ROLE_ADMIN")
openapiContext:
operationId: create-v2-feed-source
description: Creates a Feed Source resource.
summary: Creates a Feed Source resource.
tags:
- FeedSources
'_api_/feed_sources/{id}/slides_get': &ref_1
normalizationContext:
groups:
- 'playlist-slide:read'
class: ApiPlatform\Metadata\GetCollection
method: GET
provider: App\State\FeedSourceSlideProvider
filters:
- entity.search_filter
- entity.blameable_filter
- App\Filter\PublishedFilter
- entity.order_filter
- created.at.order_filter
- modified.at.order_filter
uriTemplate: '/feed-sources/{id}/slides'
openapiContext:
description: Retrieves collection of weighted slide resources (feedsource).
summary: Retrieves collection of weighted slide resources (feedsource).
operationId: get-v2-feed-source-slide-id
tags:
- FeedSources
parameters:
- schema:
type: string
format: ulid
pattern: '^[A-Za-z0-9]{26}$'
name: id
in: path
required: true
- schema:
type: integer
minimum: 0
format: int32
default: 1
in: query
name: page
required: true
- schema:
type: string
default: '10'
in: query
name: itemsPerPage
description: The number of items per page
responses:
'200':
description: OK
content:
application/ld+json:
examples:
examples: null
headers: {}

# Our DTO must be a resource to get a proper URL
# @see https://stackoverflow.com/a/75705084
# @see https://github.com/api-platform/core/issues/5451
App\Dto\FeedSource:
provider: App\State\FeedSourceProvider

operations:
ApiPlatform\Metadata\Get: *get
ApiPlatform\Metadata\Get: *ref_0
get_slides: *ref_1
5 changes: 5 additions & 0 deletions config/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,11 @@ services:
arguments:
$collectionExtensions: !tagged_iterator api_platform.doctrine.orm.query_extension.collection

App\State\FeedSourceSlideProvider:
tags: [ { name: 'api_platform.state_provider', priority: 2 } ]
arguments:
$collectionExtensions: !tagged_iterator api_platform.doctrine.orm.query_extension.collection

App\State\FeedProvider:
tags: [ { name: 'api_platform.state_provider', priority: 2 } ]
arguments:
Expand Down
11 changes: 0 additions & 11 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -386,17 +386,6 @@
<code><![CDATA[find]]></code>
</UndefinedInterfaceMethod>
</file>
<file src="src/State/FeedSourceProcessor.php">
<MissingTemplateParam>
<code><![CDATA[ProcessorInterface]]></code>
</MissingTemplateParam>
<ParamNameMismatch>
<code><![CDATA[$object]]></code>
</ParamNameMismatch>
<UndefinedDocblockClass>
<code><![CDATA[T]]></code>
</UndefinedDocblockClass>
</file>
<file src="src/State/FeedSourceProvider.php">
<PossiblyNullPropertyAssignmentValue>
<code><![CDATA[$object->getId()]]></code>
Expand Down
Loading
Loading