Pass camelCase fields in json (Downstream fix)#193
Conversation
Signed-off-by: Raunak Madan <madanraunak24@gmail.com>
|
There was a problem hiding this comment.
Code Review
This pull request updates the learning-path.json.html partial to explicitly map and format the certificate object fields into camelCase, ensuring consistency for issuing authorities and expiration data. The reviewer noted that while these changes align with the goal of using camelCase, other top-level fields in the same JSON file (such as org_id and detailed_description) still use snake_case and should be updated to maintain consistency across the entire contract.
| {{- $certificate := .Params.certificate -}} | ||
| {{- if $certificate }} | ||
| {{- $authorities := slice -}} | ||
| {{- range or (index $certificate "issuingAuthorities") (index $certificate "issuingauthorities") (index $certificate "issuing_authorities") }} | ||
| {{- $authorities = $authorities | append (dict | ||
| "name" (index . "name") | ||
| "role" (index . "role") | ||
| "signatureUrl" (or (index . "signatureUrl") (index . "signatureurl") (index . "signature_url")) | ||
| ) -}} | ||
| {{- end }} | ||
| {{- $certificateJSON := dict | ||
| "title" (index $certificate "title") | ||
| "expiresIn" (or (index $certificate "expiresIn") (index $certificate "expiresin") (index $certificate "expires_in")) | ||
| "issuingAuthorities" $authorities | ||
| -}} | ||
| "certificate": {{ $certificateJSON | jsonify }}, | ||
| {{- else }} | ||
| "certificate": null, | ||
| {{- end }} |
There was a problem hiding this comment.
While this change correctly implements camelCase for the certificate object's internal fields, the rest of the JSON contract in this file still uses snake_case for several top-level and nested fields (e.g., org_id on line 23, detailed_description on line 30, total_courses on line 55, etc.). To maintain consistency and align with the project's canonical schema as per the general rules, all field names in the emitted JSON should be converted to camelCase (e.g., orgId, detailedDescription, totalCourses). Since the PR objective is to "Pass camelCase fields in json", addressing these remaining fields would ensure a complete fix for downstream consumers.
References
- Maintain consistency in emitted JSON contracts by using camelCase for all field names (e.g., 'orgId' instead of 'org_id') to align with the project's canonical schema.
There was a problem hiding this comment.
The detailed_description have a schema drift - In downstream contract a camelCase is expected in schemas, this caused the description to be dropped in the consumer (Meshery-Cloud). I have updated it to camelCase to as per the canonical contract.
Other fields like org_id, still uses snake case in the schema contract (v1beta2), and is correctly parsed by the consumer. This would be updated when we increment meshery-cloud to use v1beta3
Signed-off-by: Raunak Madan <madanraunak24@gmail.com>
Notes for Reviewers
Emit the name of the keys explicitly as Hugo converts .Params.keys to lowercase
Signed commits