episerver / content-delivery-js-sdk

Apache License 2.0
22 stars 14 forks source link

interface SiteDefinitionLanguage Url and UrlSegment wrong casing #38

Open mathmoth opened 1 month ago

mathmoth commented 1 month ago

I noticed a discrepancy between how the interface SiteDefinitionLanguage defines Url and UrlSegment and what is returned from the Content Delivery API. In the API response these members are called url and urlSegment. Trying to access Url will always result in undefined.

JohanPetersson commented 1 month ago

Camel case is commonly used in JavaScript, that's why properties start with lowercase. JavaScript (JSON) is case-sensitive, and that's why you're getting undefined, i.e. there is no property called Url. This is the case for all objects returned by the REST API, at least for all built-in properties, the exception is your custom properties which will have the casing you have defined them with.

mathmoth commented 1 month ago

Hi Johan, I think perhaps you misunderstood my issue, I'll try to clarify:

I was referring to the interface SiteDefinitionLanguage in the content-delivery-sdk, this one right here: https://github.com/episerver/content-delivery-js-sdk/blob/master/src/%40episerver/content-delivery/src/models.mts

image

This typescript interface has Url and UrlSegment with starting uppecase, whilst the API will return the data with starting lowercase: image

So using the API and using the SDK's own typings you will get a mismatch on these properties, I was not referring to any custom properties.