influxdata / influxdata/openapi

Differentiate Task request schemas where different properties are required

Open
#598 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Shell
Stars
18
Forks
9
PR merge metrics
No merged PRs in 30d

Description

For cloud, a Task must have one of `flux` or `scriptID`. If it has `scriptID`, then it may have other fields (that aren't compatible with `flux` in a create request).
Differentiating the schemas with `oneOf` breaks the current UI tests--e.g.:

> @jstirnaman
>
> ```
> src/tasks/containers/TaskPage.test.tsx:259:66 - error TS2339: Property 'flux' does not exist on type 'TaskCreateRequest | TaskWithScriptCreateRequest'.
> Property 'flux' does not exist on type 'TaskWithScriptCreateRequest'.
> ```

I'm assuming it needs a discriminator to know which schema to use? I ran `yarn generate` to generate `src/client/*` locally and I don't even see `TaskWithScriptCreateRequest` in the results, so I 'm confused.
I'll undo this for now and move it to my _someday_ list. It seems beneficial to clients if they could discern which properties are compatible and required. I hate having it in human-readable-only fields.

_Originally posted by @jstirnaman in https://github.com/influxdata/openapi/pull/591#discussion_r1010901842_

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the schema changes discussed in pull request 591 and the generated output under src/client. Run yarn generate, then inspect src/tasks/containers/TaskPage.test.tsx around line 259 to understand the current type error. Done means the generated client exposes the differentiated Task request properties while the existing UI tests type-check.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
api
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.