Skip to content

Commit

Permalink
fix type
Browse files Browse the repository at this point in the history
Signed-off-by: Jess Frazelle <[email protected]>
  • Loading branch information
jessfraz committed Oct 17, 2024
1 parent 384ebe5 commit 44de1f5
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 34 deletions.
23 changes: 21 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ uuid = "1.11.0"
[dev-dependencies]
async-trait = "0.1"
expectorate = "1"
openapi-lint = { git = "https://github.com/oxidecomputer/openapi-lint", branch = "main" }
openapiv3 = "2"
portpicker = "0.1.1"
pretty_assertions = "1"
Expand Down
66 changes: 34 additions & 32 deletions openapi/api.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,60 +36,62 @@
"description": "Extra machine-specific information regarding a connected machine.",
"oneOf": [
{
"additionalProperties": false,
"properties": {
"Moonraker": {
"type": "object"
"type": {
"enum": [
"moonraker"
],
"type": "string"
}
},
"required": [
"Moonraker"
"type"
],
"type": "object"
},
{
"additionalProperties": false,
"properties": {
"Usb": {
"type": "object"
"type": {
"enum": [
"usb"
],
"type": "string"
}
},
"required": [
"Usb"
"type"
],
"type": "object"
},
{
"additionalProperties": false,
"properties": {
"Bambu": {
"properties": {
"current_stage": {
"allOf": [
{
"$ref": "#/components/schemas/Stage"
}
],
"description": "The current stage of the machine as defined by Bambu which can include errors, etc.",
"nullable": true
},
"nozzle_diameter": {
"allOf": [
{
"$ref": "#/components/schemas/NozzleDiameter"
}
],
"description": "The nozzle diameter of the machine."
"current_stage": {
"allOf": [
{
"$ref": "#/components/schemas/Stage"
}
],
"description": "The current stage of the machine as defined by Bambu which can include errors, etc.",
"nullable": true
},
"nozzle_diameter": {
"allOf": [
{
"$ref": "#/components/schemas/NozzleDiameter"
}
},
"required": [
"nozzle_diameter"
],
"type": "object"
"description": "The nozzle diameter of the machine."
},
"type": {
"enum": [
"bambu"
],
"type": "string"
}
},
"required": [
"Bambu"
"nozzle_diameter",
"type"
],
"type": "object"
}
Expand Down
1 change: 1 addition & 0 deletions src/server/endpoints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ pub async fn ping(_rqctx: RequestContext<Arc<Context>>) -> Result<CorsResponseOk

/// Extra machine-specific information regarding a connected machine.
#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
#[serde(rename_all = "snake_case", tag = "type")]
pub enum ExtraMachineInfoResponse {
Moonraker {},
Usb {},
Expand Down
4 changes: 4 additions & 0 deletions src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ fn test_openapi() -> TestResult {
assert!(!spec.paths.paths.is_empty());
assert!(spec.paths.paths.get("/ping").is_some());

// Check for lint errors.
let errors = openapi_lint::validate(&spec);
assert!(errors.is_empty(), "{}", errors.join("\n\n"));

// Construct a string that helps us identify the organization of tags and
// operations.
let mut ops_by_tag = BTreeMap::<String, Vec<(String, String)>>::new();
Expand Down

0 comments on commit 44de1f5

Please sign in to comment.