[][src]Function k8s_openapi_codegen_common::run

pub fn run<W>(
    definitions: &BTreeMap<DefinitionPath, Schema>,
    operations: &mut Vec<Operation>,
    definition_path: &DefinitionPath,
    map_namespace: &impl MapNamespace,
    vis: &str,
    optional_feature: Option<&str>,
    out: impl FnOnce(&[&str], Option<&str>) -> Result<W>,
    mut imports: impl FnMut(Option<String>, Option<String>) -> Result<()>
) -> Result<RunResult, Error> where
    W: Write

Each invocation of this function generates a single type specified by the definition_path parameter along with its associated API operation functions.

Parameters

  • definitions: The definitions parsed from the OpenAPI spec that should be emitted as model types.

  • operations: The list of operations parsed from the OpenAPI spec that should be emitted as API functions. Note that this value will be mutated to remove the operations that are determined to be associated with the type currently being generated.

  • definition_path: The specific definition path out of the definitions collection that should be emitted.

  • map_namespace: An instance of the MapNamespace trait that controls how OpenAPI namespaces of the definitions are mapped to rust namespaces.

  • vis: The visibility modifier that should be emitted on the generated code.

  • optional_feature: If specified, all API functions will be emitted with a #[cfg(feature = "<this value>")] attribute. The attribute will also be applied to their optional parameters and response types, if any, and to common types for optional parameters and response types that are shared by multiple operations.

  • out: A callback that will be invoked to get an impl of std::io::Write to write the generated code to. The callback receives two parameters: 1. A list of strings making up the components of the path of the generated type. Code generators that are emitting crates can use this parameter to make module subdirectories for each component, and to emit use statements in the final module's mod.rs. 1. The value of optional_feature, indicating that the generated type as a whole will be emitted under this feature. Code generators that are emitting modules can use this flag to emit a #[cfg(feature = "<this value>")] on the use statement for the generated type.

  • imports: A callback that gets invoked once for every API function that was emitted for the generated type. The callback receives two parameters: 1. The name of the optional parameters type associated with the operation, if any. 1. The name of the response type associated with the operation, if any.