datadog-api-client-typescript icon indicating copy to clipboard operation
datadog-api-client-typescript copied to clipboard

Typing Inconsistency for "v1.SearchSLOResponse" on GET /api/v1/slo endpoints

Open Vroomfrondal opened this issue 2 years ago • 5 comments

Describe the bug Bad key typing on the v1.SearchSLOResponse typescript type for GET /api/v1/slo/search. Proper response type is in snake_case while intellisense suggests camelCase for the property type.

Example 1:

const type = sloData.data.attributes.slos[0].data.attributes?.sloType // actual property is `.slo_type`

Example 2:

const status = sloData.data.attributes.slos[0].data.attributes?.overallStatus // actual property is `.overall_status`

To Reproduce

  1. in a typescript environment create a GET request to https://api.datadoghq.com/api/v1/slo/search
  2. Ensure the response type is using v1.SearchSLOResponse
  3. View the response data and observe examples listed above within code-editors intellisense

Expected behavior

  • When using the property in code you should see a snake_case suggestion.

Screenshots Screenshot 2023-12-19 at 3 01 46 PM

Environment and Versions (please complete the following information):

  • datadog/datadog-api-client version 1.19.0
  • Typescript

Vroomfrondal avatar Dec 19 '23 21:12 Vroomfrondal

Hi,

Do you have a reproducible example? Models are creating camelCase properties, which are available in my testing. Here is what I run:

import { client, v1 } from "@datadog/datadog-api-client";

const configuration = client.createConfiguration();
const apiInstance = new v1.ServiceLevelObjectivesApi(configuration);

const params: v1.ServiceLevelObjectivesApiSearchSLORequest = {
  pageSize: 20,
  pageNumber: 0,
};

apiInstance
  .searchSLO(params)
  .then((data: v1.SearchSLOResponse) => {
    console.log(data.data.attributes.slos[0].data.attributes?.sloType)
    console.log(data.data.attributes.slos[0].data.attributes?.overallStatus)
  })
  .catch((error: any) => console.error(error));

Thanks.

therve avatar Dec 21 '23 11:12 therve

Hey @therve

So that example you provided works for you? Because if asked that's the example I would provide. For me sloType and overallStatus are actually slo_type and overall_status. Requiring a @ts-expect-error for intellisense to ignore.

There are similar (but unrelated) issues like this throughout. For example, on the POST endpoint to create embedded graphs - the "size" parameter is an enum of strings (by fact and documentation) but vscode is saying it should be a number type.

Vroomfrondal avatar Dec 26 '23 17:12 Vroomfrondal

Yes that example work for me. What's your typescript version? The embedded graphs doesn't generate clients. so it's a different issue indeed.

therve avatar Dec 26 '23 17:12 therve

5.0.4, Admittedly a few behind. Maybe this was solved already?

Vroomfrondal avatar Dec 26 '23 18:12 Vroomfrondal

Thanks for your contribution!

This issue has been automatically marked as stale because it has not had activity in the last 30 days. Note that the issue will not be automatically closed, but this notification will remind us to investigate why there's been inactivity. Thank you for participating in the Datadog open source community.

If you would like this issue to remain open:

  1. Verify that you can still reproduce the issue in the latest version of this project.

  2. Comment that the issue is still reproducible and include updated details requested in the issue template.

github-actions[bot] avatar Jan 26 '24 00:01 github-actions[bot]