Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

generate types, create http client and add exemplary usage #3384

Merged
merged 25 commits into from
Nov 29, 2023

Conversation

brojd
Copy link
Contributor

@brojd brojd commented Nov 20, 2023

What this PR does

#3330

  • add a script that generates TS type definitions based on OnCall API OpenAPI schemas
  • support adding custom properties on the frontend if needed
  • add simple example of usage (for '/labels/keys/' endpoint)

Checklist

  • Unit, integration, and e2e (if applicable) tests updated
  • Documentation added (or pr:no public docs PR label added if not required)
  • CHANGELOG.md updated (or pr:no changelog PR label added if not required)

Copy link
Contributor

@joeyorlando joeyorlando left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wow 😍

@@ -41,6 +43,11 @@ export interface GroupedAlert {
render_for_web: RenderForWeb;
}

export type AlertGroup = components['schemas']['AlertGroup'] & {
loading?: boolean;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just for my own curiosity, where is this loading attribute used? Based on the name I'm guessing it's for... some loading state indicator? If so, could that state be managed external from the response objects we get back from the API? (would get rid of the need to have this type if I understand correctly)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right and yes, our plan on the frontend is to move every loading state like that to a separate dedicated store. So that they are completely separated from models/domains themselves

@brojd brojd self-assigned this Nov 27, 2023
@brojd brojd added pr:no changelog pr:no public docs Added to a PR that does not require public documentation updates labels Nov 27, 2023
@brojd brojd marked this pull request as ready for review November 27, 2023 11:38
@brojd brojd requested review from a team November 27, 2023 11:38
Copy link
Contributor

@Matvey-Kuk Matvey-Kuk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!


| :warning: WARNING |
| :------------------------------------------------------------------------------------------ |
| Transition to this approach is [in progress](https://github.com/grafana/oncall/issues/3338) |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<3

dev/.env.dev.example Outdated Show resolved Hide resolved
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit it seems most of our .yaml files use double-quotes. We might want to consider configuring the quoted-strings rule to make things consistent

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I switched to double quotes in this exact file. But across the codebase we have a mix now so yes, maybe in a separate PR we could change everything to double quotes and add a rule to yamllint

@brojd brojd requested a review from teodosii November 28, 2023 09:42
@teodosii
Copy link
Member

Looks very good 👍

@brojd brojd added this pull request to the merge queue Nov 29, 2023
Merged via the queue into dev with commit 2c4b34d Nov 29, 2023
21 checks passed
@brojd brojd deleted the brojd/generate-ts-types-from-open-api-schemas branch November 29, 2023 05:24
brojd added a commit that referenced this pull request Sep 18, 2024
# What this PR does

#3330

- add a script that generates TS type definitions based on OnCall API
OpenAPI schemas
- support adding custom properties on the frontend if needed
- add simple example of usage (for `'/labels/keys/'` endpoint)

## Checklist

- [x] Unit, integration, and e2e (if applicable) tests updated
- [x] Documentation added (or `pr:no public docs` PR label added if not
required)
- [x] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr:no public docs Added to a PR that does not require public documentation updates
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants