[MAGNOLIA-6178] Add support for Map format in YAML files for definitions that expect a List Created: 22/Apr/15  Updated: 23/Sep/15  Resolved: 28/Jul/15

Status: Closed
Project: Magnolia
Component/s: configuration
Affects Version/s: 5.4
Fix Version/s: 5.4.1

Type: Improvement Priority: Neutral
Reporter: Christopher Zimmermann Assignee: Aleksandr Pchelintcev
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: 0d
Time Spent: 0.5d
Original Estimate: Not Specified

Attachments: File html.dialog-actual.yaml     File html.dialog-proposed.yaml     File linkList.yaml    
Issue Links:
Relates
relates to MAGNOLIA-6364 Map2Bean doesn't fail with wrong gene... Closed
Template:
Acceptance criteria:
Empty
Task DoD:
[ ]* Doc/release notes changes? Comment present?
[ ]* Downstream builds green?
[ ]* Solution information and context easily available?
[ ]* Tests
[ ]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Date of First Response:
Epic Link: Config by file / code
Sprint: Sprint 4 (Basel)
Story Points: 3

 Description   

In the config app, the user works with a simple hierarchy that is configured the same when a definition expects a list or a map. node2bean handles this conversion.

But yaml configuration must currently respect the definition of a list or a map and must use dashes for a list.

This creates an additional hurdle for a developer working with configuration. For someone used to Magnolia - or someone referencing the existing body of knowledge on the internet - including documentation - an example of a "config app configuration" will not contain enough information to know how to configure a YAML file. The user will either have to know about the difference, and also have to consult the definition of the bean.

To remove this barrier to development, and to simplify documentation & training efforts, I suggest that the yaml parsing/map2bean system should accept the map configuration style (a simple hierarchy in the file with the parent being the <name> property) even when the definition expects a list.


  • Attached files with an HTML component dialog in actual and proposed variants - plus linkList.yaml which I include just as an example of somewhere a user might expect a list - that is actually a map. (the kind of thing that will confuse users)

(Note: Magnolia does not allow same name siblings, so our configuration style does not require a list. https://documentation.magnolia-cms.com/display/DOCS/Node+types#Nodetypes-Samenamesiblingsarenotallowed)



 Comments   
Comment by Aleksandr Pchelintcev [ 28/Jul/15 ]

I've made a test-shot on this issue today, the result is pushed to fix/MAGNOLIA-6178-apch
What it does essentially is following:

  • If M2B encounters a map instead of awaited list - convert map into a list.
  • since we might wanna re-use the map keys as properties for list entries ("name") - push the keys to the list elements (they're normally maps).

This seems to be what the N2B transformer's doing when setting a name property.
Not sure if it's flexible enough or whatnot, but you can give it a shot anyway.

Generated at Mon Feb 12 04:12:02 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.