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

Unnecessary allOfs in OpenAPI spec #609

Closed
david-crespo opened this issue Jan 19, 2022 · 3 comments
Closed

Unnecessary allOfs in OpenAPI spec #609

david-crespo opened this issue Jan 19, 2022 · 3 comments

Comments

@david-crespo
Copy link
Contributor

name doesn't need to be an allOf here, right? There are a few of these, most are Name but not all. @ahl

omicron/openapi/nexus.json

Lines 3862 to 3879 in 3d132cc

"OrganizationUpdate": {
"description": "Updateable properties of an [`Organization`]",
"type": "object",
"properties": {
"description": {
"nullable": true,
"type": "string"
},
"name": {
"nullable": true,
"allOf": [
{
"$ref": "#/components/schemas/Name"
}
]
}
}
},

@ahl
Copy link
Contributor

ahl commented Jan 19, 2022

I see two classes of these allOf uses: adding a description field and adding a nullable field.

In both cases, the use of allOf is necessary to add the additional field because in JSON Schema Draft 7 a $ref must be alone in an object. OpenAPI 3.0.x (which we're using) is based on JSON draft 7. OpenAPI 3.1 is based on a later draft which has greater flexibility, but the tooling ecosystem seems to be anaemic--more so than 3.0.x.

For description we need this in situations where the parameter itself is documented. I don't think this can be avoided without removing important information from the schema.

The nullable case may be avoidable, but I'm not certain of the right approach. Consider the case above of OrganizationUpdate which is really just a (flattened) wrapper around IdentityMetadataUpdateParams:

#[derive(Clone, Debug, Deserialize, Serialize, JsonSchema)]
pub struct IdentityMetadataUpdateParams {
    pub name: Option<Name>,
    pub description: Option<String>,
}

Both of these properties are optional and we can see this in the schema because neither of them is in the set of required properties. By default null is a valid value for an Option type. We could change our use of schemars so that it doesn't generate the nullable property, and that would certainly lead to a simpler spec, but since we do actually accept null as a valid value for these, we may want to preserve that expressivity.

Is the use of allOf somehow impeding you? Is this causing problems with a generator?

@david-crespo
Copy link
Contributor Author

david-crespo commented Jan 19, 2022

It's not causing me any problems, it's an easy case to handle — at least in our case where there's just one arm to the allOf. I just noticed it in the spec and didn't understand why it was there. Now I do. Thanks for the explanation!

Some of the PUT body ones might go away because of #333, but not all.

@ahl
Copy link
Contributor

ahl commented Jan 19, 2022

Glad to hear that it's not an obstacle. I agree that it's goofy! And it's good at least that if/when we go to OpenAPI 3.1 we won't have to deal with it.

leftwo pushed a commit that referenced this issue Jan 28, 2024
Crucible changes
Remove a superfluous copy during write serialization (#1087)
Update to progenitor v0.5.0, pull in required Omicron updates (#1115)
Update usdt to v0.5.0 (#1116)
Do not panic on reinitialize of a downstairs client. (#1114)
Bump (tracing-)opentelemetry(-jaeger) (#1113)
Make the Guest -> Upstairs queue fully async (#1086)
Switch to per-block ownership (#1107)
Handle timeout in the client IO task (#1109)
Enforce buffer alignment (#1106)
Block size buffers (#1105)
New dtrace probes and a counter struct in the Upstairs. (#1104)
Implement read decryption offloading (#1089)
Remove Arc + Mutex from Buffer (#1094)
Comment cleanup and rename of DsState::Repair -> Reconcile (#1102)
do not panic the dynamometer for OOB writes (#1101)
Allow dsc to start the downstairs in read-only mode. (#1098)
Use the omicron-zone-package methods for topo sorting (#1099)
Package with topological sorting (#1097)
Fix clippy lints in dsc (#1095)

Propolis changes:
PHD: demote artifact store logs to DEBUG, enable DEBUG on CI (#626)
PHD: fix missing newlines in serial.log (#622)
PHD: fix run_shell_command with multiline commands (#621)
PHD: fix `--artifact-directory` not doing anything (#618)
Update h2 dependency
Update Crucible (and Omicron) dependencies
PHD: refactor guest serial console handling (#615)
phd: add basic "migration-from-base" tests + machinery (#609)
phd: Ensure min disk size fits read-only parents (#611)
phd: automatically fetch `crucible-downstairs` from Buildomat (#604)
Mitigate behavior from illumos#16183
PHD: add guest adapter for WS2022 (#607)
phd: include error cause chain in failure output (#606)
add QEMU pvpanic ISA device (#596)
Add crucible-mem backend
Make crucible opt parsing more terse in standalone
leftwo added a commit that referenced this issue Jan 29, 2024
Crucible changes
Remove a superfluous copy during write serialization (#1087) Update to
progenitor v0.5.0, pull in required Omicron updates (#1115) Update usdt
to v0.5.0 (#1116)
Do not panic on reinitialize of a downstairs client. (#1114) Bump
(tracing-)opentelemetry(-jaeger) (#1113)
Make the Guest -> Upstairs queue fully async (#1086) Switch to per-block
ownership (#1107)
Handle timeout in the client IO task (#1109)
Enforce buffer alignment (#1106)
Block size buffers (#1105)
New dtrace probes and a counter struct in the Upstairs. (#1104)
Implement read decryption offloading (#1089)
Remove Arc + Mutex from Buffer (#1094)
Comment cleanup and rename of DsState::Repair -> Reconcile (#1102) do
not panic the dynamometer for OOB writes (#1101) Allow dsc to start the
downstairs in read-only mode. (#1098) Use the omicron-zone-package
methods for topo sorting (#1099) Package with topological sorting
(#1097)
Fix clippy lints in dsc (#1095)

Propolis changes:
PHD: demote artifact store logs to DEBUG, enable DEBUG on CI (#626) 
PHD: fix missing newlines in serial.log (#622)
PHD: fix run_shell_command with multiline commands (#621) 
PHD: fix `--artifact-directory` not doing anything (#618) Update h2
dependency
Update Crucible (and Omicron) dependencies
PHD: refactor guest serial console handling (#615) 
phd: add basic "migration-from-base" tests + machinery (#609) 
phd: Ensure min disk size fits read-only parents (#611) 
phd: automatically fetch `crucible-downstairs` from Buildomat (#604)
Mitigate behavior from illumos#16183
PHD: add guest adapter for WS2022 (#607)
phd: include error cause chain in failure output (#606) add QEMU pvpanic
ISA device (#596)
Add crucible-mem backend
Make crucible opt parsing more terse in standalone

Co-authored-by: Alan Hanson <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants