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

Update dropshot and openapiv3 deps #4488

Merged
merged 1 commit into from
Nov 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 35 additions & 25 deletions Cargo.lock

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

24 changes: 12 additions & 12 deletions internal-dns/tests/output/test-server.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,6 @@
}
},
"components": {
"responses": {
"Error": {
"description": "Error",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
}
},
"schemas": {
"Error": {
"description": "Error information from a response.",
Expand All @@ -65,6 +53,18 @@
"request_id"
]
}
},
"responses": {
"Error": {
"description": "Error",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
}
}
}
}
20 changes: 16 additions & 4 deletions nexus/src/bin/nexus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ struct Args {
short = 'O',
long = "openapi",
help = "Print the external OpenAPI Spec document and exit",
conflicts_with = "openapi_internal",
action
)]
openapi: bool,
Expand All @@ -40,7 +41,7 @@ struct Args {
openapi_internal: bool,

#[clap(name = "CONFIG_FILE_PATH", action)]
config_file_path: PathBuf,
config_file_path: Option<PathBuf>,
}

#[tokio::main]
Expand All @@ -53,14 +54,25 @@ async fn main() {
async fn do_run() -> Result<(), CmdError> {
let args = Args::parse();

let config = Config::from_file(args.config_file_path)
.map_err(|e| CmdError::Failure(anyhow!(e)))?;

if args.openapi {
run_openapi_external().map_err(|err| CmdError::Failure(anyhow!(err)))
} else if args.openapi_internal {
run_openapi_internal().map_err(|err| CmdError::Failure(anyhow!(err)))
} else {
let config_path = match args.config_file_path {
Some(path) => path,
None => {
use clap::CommandFactory;

eprintln!("{}", Args::command().render_help());
return Err(CmdError::Usage(
"CONFIG_FILE_PATH is required".to_string(),
));
}
};
let config = Config::from_file(config_path)
.map_err(|e| CmdError::Failure(anyhow!(e)))?;

run_server(&config).await.map_err(|err| CmdError::Failure(anyhow!(err)))
}
}
15 changes: 11 additions & 4 deletions nexus/tests/output/cmd-nexus-noargs-stderr
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
error: the following required arguments were not provided:
<CONFIG_FILE_PATH>
See README.adoc for more information

Usage: nexus <CONFIG_FILE_PATH>
Usage: nexus [OPTIONS] [CONFIG_FILE_PATH]

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think what is supported is:
nexus -i
or
nexus -o
or
nexus <config_file_path>

I don't know how to make Clap enforce that though, and what you have here essentially does the same
thing anyway.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Frankly, I'd like to change nexus to operate like nexus run <cfg> or nexus openapi like all (?) of the other openapi servers in omicron. Updating this was a stop-gap so I could get it to emit openapi docs for me without having to rustle up a valid configuration.

For more information, try '--help'.
Arguments:
[CONFIG_FILE_PATH]

Options:
-O, --openapi Print the external OpenAPI Spec document and exit
-I, --openapi-internal Print the internal OpenAPI Spec document and exit
-h, --help Print help

nexus: CONFIG_FILE_PATH is required
24 changes: 12 additions & 12 deletions openapi/bootstrap-agent.json
Original file line number Diff line number Diff line change
Expand Up @@ -160,18 +160,6 @@
}
},
"components": {
"responses": {
"Error": {
"description": "Error",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
}
},
"schemas": {
"Baseboard": {
"description": "Describes properties that should uniquely identify a Gimlet.",
Expand Down Expand Up @@ -977,6 +965,18 @@
"description": "Names must begin with a lower case ASCII letter, be composed exclusively of lowercase ASCII, uppercase ASCII, numbers, and '-', and may not end with a '-'. Names cannot be a UUID though they may contain a UUID.",
"type": "string"
}
},
"responses": {
"Error": {
"description": "Error",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
}
}
}
}
24 changes: 12 additions & 12 deletions openapi/dns-server.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,18 +54,6 @@
}
},
"components": {
"responses": {
"Error": {
"description": "Error",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
}
},
"schemas": {
"DnsConfig": {
"type": "object",
Expand Down Expand Up @@ -251,6 +239,18 @@
"weight"
]
}
},
"responses": {
"Error": {
"description": "Error",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
}
}
}
}
Loading
Loading