oxidecomputer / oxidecomputer/omicron

[nexus] OpenAPI schema not marking required query params required

Open
#7,155 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
572
Forks
97
Avg merge
2d 12h
Merged PRs (30d)
96

Description

The selector struct (correct)

InternetGatewaySelector selects a gateway. It correctly has a required gateway field and optional project and vpc, representing the possibility of selecting by gateway ID, in which case neither of the parent identifiers can be included.

https://github.com/oxidecomputer/omicron/blob/adaa2ecee45b5e1734e2a2820bcf3d208c31285c/nexus/types/src/external_api/params.rs#L319-L326

The endpoints

These two endpoints use InternetGatewaySelector as their query params to select a gateway. The fact that

https://github.com/oxidecomputer/omicron/blob/adaa2ecee45b5e1734e2a2820bcf3d208c31285c/nexus/external-api/src/lib.rs#L2260-L2274

https://github.com/oxidecomputer/omicron/blob/adaa2ecee45b5e1734e2a2820bcf3d208c31285c/nexus/external-api/src/lib.rs#L2300-L2314

The OpenAPI schema (wrong)

The gateway query param is optional, but it should not be.

https://github.com/oxidecomputer/omicron/blob/adaa2ecee45b5e1734e2a2820bcf3d208c31285c/openapi/nexus.json#L2685-L2694

https://github.com/oxidecomputer/omicron/blob/adaa2ecee45b5e1734e2a2820bcf3d208c31285c/openapi/nexus.json#L2895-L2904

The TypeScript type generated accordingly

https://github.com/oxidecomputer/console/blob/653b572/app/api/__generated__/Api.ts#L4541-L4548

export interface InternetGatewayIpPoolListQueryParams {
  gateway?: NameOrId
  limit?: number
  pageToken?: string
  project?: NameOrId
  sortBy?: NameOrIdSortMode
  vpc?: NameOrId
}

What a required query param looks like

https://github.com/oxidecomputer/omicron/blob/adaa2ecee45b5e1734e2a2820bcf3d208c31285c/openapi/nexus.json#L1824-L1840

An unrelated endpoint with the same issue

This suggests it might have something to do with nesting it in the pagination thing.

https://github.com/oxidecomputer/omicron/blob/adaa2ecee45b5e1734e2a2820bcf3d208c31285c/nexus/external-api/src/lib.rs#L1751-L1760

Contributor guide

Open the contributing guide

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 InternetGatewaySelector definition in nexus/types/src/external_api/params.rs and the two endpoint definitions in nexus/external-api/src/lib.rs. Compare their entries in openapi/nexus.json with the required-query-parameter example, then inspect the unrelated paginated endpoint for the shared schema-generation pattern. Done means the gateway parameter is marked required in both schemas and the generated TypeScript type reflects that.

Written by the indexing model from the issue text.

Assessment

Tech stack
openapi, rust
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.