Skip to content

Generate clients from openapi documents #369

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

Merged
merged 15 commits into from
Nov 10, 2021
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
180 changes: 174 additions & 6 deletions Cargo.lock

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

9 changes: 9 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,19 @@ panic = "abort"
#[patch."https://github.com/oxidecomputer/steno"]
#steno = { path = "../steno" }

#
# Local client generation during development.
#
#[patch."https://github.com/oxidecomputer/progenitor"]
#progenitor = { path = "../progenitor/progenitor" }
#[patch."https://github.com/oxidecomputer/typify"]
#typify = { path = "../typify/typify" }

#
# We maintain a fork of pq-sys to address upstream issues. See the
# README.oxide.md in the "oxide" branch of our fork for details.
#
[patch.crates-io.pq-sys]
git = 'https://github.com/oxidecomputer/pq-sys'
branch = "oxide/omicron"

2 changes: 2 additions & 0 deletions common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ tempfile = "3.0"
thiserror = "1.0"
toml = "0.5.6"
walkdir = "2.3"
progenitor = { git = "https://github.com/oxidecomputer/progenitor" }
percent-encoding = "2.1.0"

[dependencies.api_identity]
path = "src/api/external/api_identity"
Expand Down
32 changes: 1 addition & 31 deletions common/src/api/external/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use crate::api::external::Name;
use crate::api::external::ResourceType;
use dropshot::HttpError;
use dropshot::HttpErrorResponseBody;
use serde::Deserialize;
use serde::Serialize;
use uuid::Uuid;
Expand Down Expand Up @@ -144,36 +143,6 @@ impl Error {
pub fn unavail(message: &str) -> Error {
Error::ServiceUnavailable { internal_message: message.to_owned() }
}

/**
* Given an error returned in an HTTP response, reconstitute an `Error`
* that describes that error. This is intended for use when returning an
* error from one control plane service to another while preserving
* information about the error. If the error is of an unknown kind or
* doesn't match the expected form, an internal error will be returned.
*/
pub fn from_response(
error_message_base: String,
error_response: HttpErrorResponseBody,
) -> Error {
/*
* We currently only handle the simple case of an InvalidRequest because
* that's the only case that we currently use. If we want to preserve
* others of these (e.g., ObjectNotFound), we will probably need to
* include more information in the HttpErrorResponseBody.
*/
match error_response.error_code.as_deref() {
Some("InvalidRequest") => {
Error::InvalidRequest { message: error_response.message }
}
_ => Error::InternalError {
internal_message: format!(
"{}: unknown error from dependency: {:?}",
error_message_base, error_response
),
},
}
}
}

impl From<Error> for HttpError {
Expand Down Expand Up @@ -287,6 +256,7 @@ mod test {

#[test]
fn test_bail_unless() {
#![allow(clippy::eq_op)]
/* Success cases */
let no_bail = || {
bail_unless!(1 + 1 == 2, "wrong answer: {}", 3);
Expand Down
Loading