influxdata / influxdata/influxdb

Update swagger Dashboard Colors to be types individual types usign OneOf for validation

Open
#17,030 0 comments 0 reactions 0 assignees View on GitHub
good-first-issue kind/bug
Dominant language
Rust
Stars
31.7k
Forks
3.7k
Avg merge
13h 37m
Merged PRs (30d)
8

Description

Right now we have the following, which doesn't validatie the needs of a given view. This allows for any colors to be provided, not necessarily the ones that are required. I'd recommend making these color validations accurate, where for `Gauge` it would require the `min` and `max` for instance. I'm assuming these are required for gauge, that may be in error. Would be nice to provide swagger that provides a wholistic view of the View properties' color requirements.

```yml
GaugeViewProperties:
type: object
required: [type, queries, colors, shape, note, showNoteWhenEmpty, prefix, tickPrefix, suffix, tickSuffix, legend, decimalPlaces]
properties:
type:
type: string
enum: [gauge]
queries:
type: array
items:
$ref: "#/components/schemas/DashboardQuery"
colors:
description: Colors define color encoding of data into a visualization
type: array
items:
$ref: "#/components/schemas/DashboardColor"
shape:
type: string
enum: ['chronograf-v2']
note:
type: string
showNoteWhenEmpty:
description: If true, will display note when empty
type: boolean
prefix:
type: string
tickPrefix:
type: string
suffix:
type: string
tickSuffix:
type: string
legend:
$ref: '#/components/schemas/Legend'
decimalPlaces:
$ref: "#/components/schemas/DecimalPlaces"

# snip
DashboardColor:
type: object
description: Defines an encoding of data value into color space.
required: [id, type, hex, name, value]
properties:
id:
description: The unique ID of the view color.
type: string
type:
description: Type is how the color is used.
type: string
enum:
- min
- max
- threshold
- scale
- text
- background
hex:
description: The hex number of the color
type: string
maxLength: 7
minLength: 7
name:
description: The user-facing name of the hex color.
type: string
value:
description: The data value mapped to this color.
type: number
format: float
```

Contributor guide

Open the contributing guide

Research direction

Start with the GaugeViewProperties and DashboardColor schemas shown in the issue, then locate the corresponding OpenAPI component definitions for the other view types. Confirm each view's required color types and fields, especially whether Gauge requires min and max, and consider the work complete when the schema gives per-view color requirements through oneOf validation.

Written by the indexing model from the issue text.

Assessment

Tech stack
openapi
Domain
api, backend-api-design
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.