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

Change dialog content from List to concrete object #891

Closed
4 tasks done
oskogstad opened this issue Jul 3, 2024 · 1 comment
Closed
4 tasks done

Change dialog content from List to concrete object #891

oskogstad opened this issue Jul 3, 2024 · 1 comment
Assignees

Comments

@oskogstad
Copy link
Collaborator

oskogstad commented Jul 3, 2024

Description

Instead of Content being a list:

"content": [
            {
              "type": "TITLE",
              "mediaType": null,
              "value": [
                {
                  "value": "Fin tittel",
                  "languageCode": "nb"
                }
              ]
            },
            ...

Content as an object with named properties for each content type:

"content": {
   "title": {
       "value": [ { "value": "Fin tittel", "languageCode": "nb" } ]},
       "mediaType": "text/plain"
   "summary": { ...},
   "extendedStatus": { ... },
}

This will make the API much easier to understand and use for front-end

Implementation

Make a new model class for the APIs and map from the abstract lookup type
Maybe add test to ensure these two match, so that if the lookup type is updated, the outer facing class is updated as well

Tasks

Preview Give feedback

Threat modelling

Preview Give feedback

Acceptance criteria

GIVEN ...
WHEN ....
THEN ...

GIVEN ...
WHEN ....
THEN ...

@elsand
Copy link
Member

elsand commented Jul 18, 2024

As an added bonus, this will make PATCH operations much cleaner since one does not have to know the actual index of the content you want to change. Do note though, that we want to have this content on transmissions as well, where there will be different validation rules, which might affect nullability of some of these fields.

oskogstad added a commit that referenced this issue Jul 24, 2024
… type (#905)

#891 

Changes content on the API layers to be an object with all content types
as properties.
Required props are non-nullable, the rest is nullable.

Validators are re-written to use reflection, all DialogContentTypes are
looked up on the incomming DTOs
Tests have been added to ensure that ContentDTOs prop. count matches
those of DialogContentTypes

There is some weird naming/mapping stuff when it comes to the search
mapping, but it works OK, see comments 🙈

Co-authored-by: Knut Haug <knut.espen.haug@digdir.no>
@elsand elsand closed this as completed Aug 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants