[MGNLREST-333] REST endpoints returns a String value regardless of the data type Created: 05/Nov/21  Updated: 13/Jul/22  Resolved: 14/Mar/22

Status: Closed
Project: Magnolia REST Framework
Component/s: delivery
Affects Version/s: 2.2.9
Fix Version/s: 2.2.12

Type: Bug Priority: Neutral
Reporter: Roberto Gaona Assignee: Chuong Doan Huy
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: 2d 0.5h
Original Estimate: Not Specified

Issue Links:
Cloners
is cloned by MGNLREST-403 REST endpoints returns a String value... Closed
Problem/Incident
Template:
Acceptance criteria:
Empty
Task DoD:
[X]* Doc/release notes changes? Comment present?
[X]* Downstream builds green?
[X]* Solution information and context easily available?
[X]* Tests
[X]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Bug DoR:
[ ]* Steps to reproduce, expected, and actual results filled
[ ]* Affected version filled
Date of First Response:
Epic Link: Support
Sprint: DevX 5
Story Points: 3
Team: DeveloperX

 Description   

Steps to reproduce

  1.  Configure any JCR property with a type Double
  2.  Retrieve such property via Delivery API and see that no type is specified for it

This seems to cause that, per example, in React SPAs, the values recovered by components and the like is always of type String rather than the defined value.

Expected results

Numeric values should be returned without quotation to facilitate handling.

Actual results

Values are always returned on String format.

Workaround

Data can be casted to the desired type after retrieving the values on the client side

Development notes



 Comments   
Comment by Christopher Zimmermann [ 11/Jan/22 ]

Ticket description has been adjusted based on comments discussion. This ticket does not "add" aa type property - it just returns the properties in the proper format (ie only quoting values that are actually string type.)

Comment by Jaroslav Simak [ 12/Jan/22 ]

Problem most likely lies in the info.magnolia.rest.delivery.jcr.NodeWriter#writeProperty method, where string is always returned for the property value.

See also how GraphQL does this: https://git.magnolia-cms.com/projects/ENTERPRISE/repos/graphql/browse/magnolia-graphql-jcr/src/main/java/info/magnolia/graphql/jcr/datafetcher/JcrPropertyDataFetcher.java

Generated at Mon Feb 12 06:58:53 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.