Skip to content

Commit

Permalink
Make naming conform to openapi-lint (#610)
Browse files Browse the repository at this point in the history
  • Loading branch information
ahl authored Jan 20, 2022
1 parent 3d132cc commit fcf53ca
Show file tree
Hide file tree
Showing 15 changed files with 186 additions and 205 deletions.
13 changes: 10 additions & 3 deletions Cargo.lock

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

43 changes: 13 additions & 30 deletions common/src/api/external/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,6 @@ where
* Identity-related metadata that's included in nearly all public API objects
*/
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize, JsonSchema)]
#[serde(rename_all = "camelCase")]
pub struct IdentityMetadata {
/** unique, immutable, system-controlled identifier for each resource */
pub id: Uuid,
Expand All @@ -623,7 +622,6 @@ pub struct IdentityMetadata {
* Create-time identity-related parameters
*/
#[derive(Clone, Debug, Deserialize, Serialize, JsonSchema)]
#[serde(rename_all = "camelCase")]
pub struct IdentityMetadataCreateParams {
pub name: Name,
pub description: String,
Expand All @@ -633,7 +631,6 @@ pub struct IdentityMetadataCreateParams {
* Updateable identity-related parameters
*/
#[derive(Clone, Debug, Deserialize, Serialize, JsonSchema)]
#[serde(rename_all = "camelCase")]
pub struct IdentityMetadataUpdateParams {
pub name: Option<Name>,
pub description: Option<String>,
Expand Down Expand Up @@ -665,7 +662,7 @@ pub struct IdentityMetadataUpdateParams {
Serialize,
JsonSchema,
)]
#[serde(rename_all = "lowercase")]
#[serde(rename_all = "snake_case")]
pub enum InstanceState {
Creating, /* TODO-polish: paper over Creating in the API with Starting? */
Starting,
Expand Down Expand Up @@ -772,7 +769,6 @@ impl From<&InstanceCpuCount> for i64 {
* Client view of an [`InstanceRuntimeState`]
*/
#[derive(Clone, Debug, Deserialize, Serialize, JsonSchema)]
#[serde(rename_all = "camelCase")]
pub struct InstanceRuntimeState {
pub run_state: InstanceState,
pub time_run_state_updated: DateTime<Utc>,
Expand All @@ -793,7 +789,6 @@ impl From<crate::api::internal::nexus::InstanceRuntimeState>
* Client view of an [`Instance`]
*/
#[derive(ObjectIdentity, Clone, Debug, Deserialize, Serialize, JsonSchema)]
#[serde(rename_all = "camelCase")]
pub struct Instance {
/* TODO is flattening here the intent in RFD 4? */
#[serde(flatten)]
Expand Down Expand Up @@ -821,7 +816,6 @@ pub struct Instance {
* Client view of an [`Disk`]
*/
#[derive(ObjectIdentity, Clone, Debug, Deserialize, Serialize, JsonSchema)]
#[serde(rename_all = "camelCase")]
pub struct Disk {
#[serde(flatten)]
pub identity: IdentityMetadata,
Expand All @@ -846,8 +840,7 @@ pub struct Disk {
Serialize,
JsonSchema,
)]
#[serde(rename_all = "lowercase")]
#[serde(tag = "state", content = "instance")]
#[serde(tag = "state", content = "instance", rename_all = "snake_case")]
pub enum DiskState {
/** Disk is being initialized */
Creating,
Expand Down Expand Up @@ -986,17 +979,15 @@ impl From<steno::SagaView> for Saga {
}

#[derive(Clone, Debug, Serialize, JsonSchema)]
#[serde(rename_all = "camelCase")]
#[serde(tag = "state")]
#[serde(tag = "state", rename_all = "snake_case")]
pub enum SagaState {
Running,
Succeeded,
Failed { error_node_name: String, error_info: SagaErrorInfo },
}

#[derive(Clone, Debug, Serialize, JsonSchema)]
#[serde(rename_all = "camelCase")]
#[serde(tag = "error")]
#[serde(tag = "error", rename_all = "snake_case")]
pub enum SagaErrorInfo {
ActionFailed { source_error: serde_json::Value },
DeserializeFailed { message: String },
Expand Down Expand Up @@ -1150,7 +1141,7 @@ impl JsonSchema for Ipv6Net {
}

#[derive(Clone, Copy, Debug, Deserialize, Serialize, PartialEq, JsonSchema)]
#[serde(rename_all = "camelCase")]
#[serde(rename_all = "snake_case")]
pub enum VpcRouterKind {
System,
Custom,
Expand All @@ -1159,7 +1150,6 @@ pub enum VpcRouterKind {
/// A VPC router defines a series of rules that indicate where traffic
/// should be sent depending on its destination.
#[derive(ObjectIdentity, Clone, Debug, Deserialize, Serialize, JsonSchema)]
#[serde(rename_all = "camelCase")]
pub struct VpcRouter {
/// common identifying metadata
#[serde(flatten)]
Expand Down Expand Up @@ -1197,8 +1187,7 @@ pub enum NetworkTarget {
/// A subset of [`NetworkTarget`], `RouteTarget` specifies all
/// possible targets that a route can forward to.
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, JsonSchema)]
#[serde(rename_all = "camelCase")]
#[serde(tag = "type", content = "value")]
#[serde(tag = "type", content = "value", rename_all = "snake_case")]
pub enum RouteTarget {
Ip(IpAddr),
Vpc(Name),
Expand Down Expand Up @@ -1270,8 +1259,7 @@ impl Display for RouteTarget {
/// the kind of network traffic that will be matched to be forwarded
/// to the [`RouteTarget`].
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, JsonSchema)]
#[serde(rename_all = "camelCase")]
#[serde(tag = "type", content = "value")]
#[serde(tag = "type", content = "value", rename_all = "snake_case")]
pub enum RouteDestination {
Ip(IpAddr),
Vpc(Name),
Expand Down Expand Up @@ -1338,6 +1326,7 @@ impl Display for RouteDestination {
Clone, Copy, Debug, PartialEq, Deserialize, Serialize, Display, JsonSchema,
)]
#[display("{}")]
#[serde(rename_all = "snake_case")]
pub enum RouterRouteKind {
/// Determines the default destination of traffic, such as whether it goes to the internet or not.
///
Expand All @@ -1364,7 +1353,6 @@ pub enum RouterRouteKind {

/// A route defines a rule that governs where traffic should be sent based on its destination.
#[derive(ObjectIdentity, Clone, Debug, Deserialize, Serialize, JsonSchema)]
#[serde(rename_all = "camelCase")]
pub struct RouterRoute {
/// common identifying metadata
#[serde(flatten)]
Expand All @@ -1382,7 +1370,6 @@ pub struct RouterRoute {

/// Create-time parameters for a [`RouterRoute`]
#[derive(Clone, Debug, Deserialize, Serialize, JsonSchema)]
#[serde(rename_all = "camelCase")]
pub struct RouterRouteCreateParams {
#[serde(flatten)]
pub identity: IdentityMetadataCreateParams,
Expand All @@ -1392,7 +1379,6 @@ pub struct RouterRouteCreateParams {

/// Updateable properties of a [`RouterRoute`]
#[derive(Clone, Debug, Deserialize, Serialize, JsonSchema)]
#[serde(rename_all = "camelCase")]
pub struct RouterRouteUpdateParams {
#[serde(flatten)]
pub identity: IdentityMetadataUpdateParams,
Expand Down Expand Up @@ -1523,21 +1509,21 @@ pub enum VpcFirewallRuleProtocol {
}

#[derive(Clone, Copy, Debug, Deserialize, Serialize, PartialEq, JsonSchema)]
#[serde(rename_all = "camelCase")]
#[serde(rename_all = "snake_case")]
pub enum VpcFirewallRuleStatus {
Disabled,
Enabled,
}

#[derive(Clone, Copy, Debug, Deserialize, Serialize, PartialEq, JsonSchema)]
#[serde(rename_all = "camelCase")]
#[serde(rename_all = "snake_case")]
pub enum VpcFirewallRuleDirection {
Inbound,
Outbound,
}

#[derive(Clone, Copy, Debug, Deserialize, Serialize, PartialEq, JsonSchema)]
#[serde(rename_all = "camelCase")]
#[serde(rename_all = "snake_case")]
pub enum VpcFirewallRuleAction {
Allow,
Deny,
Expand All @@ -1546,8 +1532,7 @@ pub enum VpcFirewallRuleAction {
/// A subset of [`NetworkTarget`], `VpcFirewallRuleTarget` specifies all
/// possible targets that a firewall rule can be attached to.
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, JsonSchema)]
#[serde(rename_all = "camelCase")]
#[serde(tag = "type", content = "value")]
#[serde(tag = "type", content = "value", rename_all = "snake_case")]
pub enum VpcFirewallRuleTarget {
Vpc(Name),
Subnet(Name),
Expand Down Expand Up @@ -1617,8 +1602,7 @@ impl Display for VpcFirewallRuleTarget {
/// A subset of [`NetworkTarget`], `VpcFirewallRuleHostFilter` specifies all
/// possible targets that a route can forward to.
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, JsonSchema)]
#[serde(rename_all = "camelCase")]
#[serde(tag = "type", content = "value")]
#[serde(tag = "type", content = "value", rename_all = "snake_case")]
pub enum VpcFirewallRuleHostFilter {
Vpc(Name),
Subnet(Name),
Expand Down Expand Up @@ -1893,7 +1877,6 @@ impl JsonSchema for MacAddr {

/// A `NetworkInterface` represents a virtual network interface device.
#[derive(ObjectIdentity, Clone, Debug, Deserialize, JsonSchema, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct NetworkInterface {
/// common identifying metadata
#[serde(flatten)]
Expand Down
2 changes: 1 addition & 1 deletion nexus/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ expectorate = "1.0.4"
nexus-test-utils-macros = { path = "test-utils-macros" }
nexus-test-utils = { path = "test-utils" }
omicron-test-utils = { path = "../test-utils" }
openapiv3 = "1.0.0-beta.5"
openapiv3 = "1.0"
subprocess = "0.2.8"

[dev-dependencies.openapi-lint]
Expand Down
1 change: 0 additions & 1 deletion nexus/src/external_api/console_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ use std::{collections::HashSet, ffi::OsString, path::PathBuf, sync::Arc};
use uuid::Uuid;

#[derive(Clone, Debug, Deserialize, Serialize, JsonSchema)]
#[serde(rename_all = "camelCase")]
pub struct LoginParams {
pub username: String,
}
Expand Down
15 changes: 0 additions & 15 deletions nexus/src/external_api/params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ use uuid::Uuid;
* Create-time parameters for an [`Organization`]
*/
#[derive(Clone, Debug, Deserialize, Serialize, JsonSchema)]
#[serde(rename_all = "camelCase")]
pub struct OrganizationCreate {
#[serde(flatten)]
pub identity: IdentityMetadataCreateParams,
Expand All @@ -32,7 +31,6 @@ pub struct OrganizationCreate {
* Updateable properties of an [`Organization`]
*/
#[derive(Clone, Debug, Deserialize, Serialize, JsonSchema)]
#[serde(rename_all = "camelCase")]
pub struct OrganizationUpdate {
#[serde(flatten)]
pub identity: IdentityMetadataUpdateParams,
Expand All @@ -46,7 +44,6 @@ pub struct OrganizationUpdate {
* Create-time parameters for a [`Project`]
*/
#[derive(Clone, Debug, Deserialize, Serialize, JsonSchema)]
#[serde(rename_all = "camelCase")]
pub struct ProjectCreate {
#[serde(flatten)]
pub identity: IdentityMetadataCreateParams,
Expand All @@ -56,7 +53,6 @@ pub struct ProjectCreate {
* Updateable properties of a [`Project`]
*/
#[derive(Clone, Debug, Deserialize, Serialize, JsonSchema)]
#[serde(rename_all = "camelCase")]
pub struct ProjectUpdate {
#[serde(flatten)]
pub identity: IdentityMetadataUpdateParams,
Expand All @@ -70,7 +66,6 @@ pub struct ProjectUpdate {
* Create-time parameters for a [`NetworkInterface`]
*/
#[derive(Clone, Debug, Deserialize, Serialize, JsonSchema)]
#[serde(rename_all = "camelCase")]
pub struct NetworkInterfaceCreate {
#[serde(flatten)]
pub identity: IdentityMetadataCreateParams,
Expand All @@ -84,7 +79,6 @@ pub struct NetworkInterfaceCreate {
* Create-time parameters for an [`Instance`]
*/
#[derive(Clone, Debug, Deserialize, Serialize, JsonSchema)]
#[serde(rename_all = "camelCase")]
pub struct InstanceCreate {
#[serde(flatten)]
pub identity: IdentityMetadataCreateParams,
Expand All @@ -101,7 +95,6 @@ pub struct InstanceCreate {
* Create-time parameters for a [`Vpc`]
*/
#[derive(Clone, Debug, Deserialize, Serialize, JsonSchema)]
#[serde(rename_all = "camelCase")]
pub struct VpcCreate {
#[serde(flatten)]
pub identity: IdentityMetadataCreateParams,
Expand All @@ -112,7 +105,6 @@ pub struct VpcCreate {
* Updateable properties of a [`Vpc`]
*/
#[derive(Clone, Debug, Deserialize, Serialize, JsonSchema)]
#[serde(rename_all = "camelCase")]
pub struct VpcUpdate {
#[serde(flatten)]
pub identity: IdentityMetadataUpdateParams,
Expand All @@ -123,7 +115,6 @@ pub struct VpcUpdate {
* Create-time parameters for a [`VpcSubnet`]
*/
#[derive(Clone, Debug, Deserialize, Serialize, JsonSchema)]
#[serde(rename_all = "camelCase")]
pub struct VpcSubnetCreate {
#[serde(flatten)]
pub identity: IdentityMetadataCreateParams,
Expand All @@ -135,7 +126,6 @@ pub struct VpcSubnetCreate {
* Updateable properties of a [`VpcSubnet`]
*/
#[derive(Clone, Debug, Deserialize, Serialize, JsonSchema)]
#[serde(rename_all = "camelCase")]
pub struct VpcSubnetUpdate {
#[serde(flatten)]
pub identity: IdentityMetadataUpdateParams,
Expand All @@ -149,15 +139,13 @@ pub struct VpcSubnetUpdate {

/// Create-time parameters for a [`VpcRouter`]
#[derive(Clone, Debug, Deserialize, Serialize, JsonSchema)]
#[serde(rename_all = "camelCase")]
pub struct VpcRouterCreate {
#[serde(flatten)]
pub identity: IdentityMetadataCreateParams,
}

/// Updateable properties of a [`VpcRouter`]
#[derive(Clone, Debug, Deserialize, Serialize, JsonSchema)]
#[serde(rename_all = "camelCase")]
pub struct VpcRouterUpdate {
#[serde(flatten)]
pub identity: IdentityMetadataUpdateParams,
Expand All @@ -171,7 +159,6 @@ pub struct VpcRouterUpdate {
* Create-time parameters for a [`Disk`]
*/
#[derive(Clone, Debug, Deserialize, Serialize, JsonSchema)]
#[serde(rename_all = "camelCase")]
pub struct DiskCreate {
/** common identifying metadata */
#[serde(flatten)]
Expand All @@ -186,7 +173,6 @@ pub struct DiskCreate {
* Parameters for the [`Disk`] to be attached or detached to an instance
*/
#[derive(Clone, Debug, Deserialize, Serialize, JsonSchema)]
#[serde(rename_all = "camelCase")]
pub struct DiskIdentifier {
pub disk: Name,
}
Expand All @@ -203,7 +189,6 @@ pub struct DiskIdentifier {
* Create-time parameters for a [`UserBuiltin`]
*/
#[derive(Clone, Debug, Deserialize, Serialize, JsonSchema)]
#[serde(rename_all = "camelCase")]
pub struct UserBuiltinCreate {
#[serde(flatten)]
pub identity: IdentityMetadataCreateParams,
Expand Down
Loading

0 comments on commit fcf53ca

Please sign in to comment.