1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/*!
Combined crate for all Atelier sub-crates incorporated as features. Atelier is a Rust native
library, and tools, for the AWS [Smithy](https://github.com/awslabs/smithy) Interface Definition
Language.

The aim of this crate is to provide a single client interface over a set of crates that provide
different Atelier capabilities. The following table shows the mapping from individual crate to the
combined module path in this library. The column _Default_ indicates those that are included in the
default feature, although the core will be included regardless of any feature selection.

| Feature name | Default | Individual crate                                    | Target module path                | Purpose                                               |
|--------------|---------|-----------------------------------------------------|-----------------------------------|-------------------------------------------------------|
| N/A          | **Yes** | [atelier_core](https://docs.rs/atelier_core)        | `atelier_lib::core`               | Core models only.                                     |
| "json"       | No      | [atelier_json](https://docs.rs/atelier_json)        | `atelier_lib::format::json`       | Reading and Writing JSON AST representation.          |
| "openapi"    | No      | [atelier_openapi](https://docs.rs/atelier_openapi)  | `atelier_lib::format::openapi`    | Reading and Writing OpenAPI representations.          |
| "smithy"     | Yes     | [atelier_smithy](https://docs.rs/atelier_smithy)    | `atelier_lib::format::smithy`     | Reading and Writing the Smithy native representation. |

*/

#![warn(
    // ---------- Stylistic
    future_incompatible,
    nonstandard_style,
    rust_2018_idioms,
    // ---------- Public
    missing_debug_implementations,
    missing_docs,
    unreachable_pub,
)]

pub use atelier_core as core;

#[cfg(any(feature = "json", feature = "openapi", feature = "smithy"))]
#[doc = "Child modules that implement `Reader` and `Writer` for specific representations."]
pub mod format {
    #[cfg(feature = "json")]
    pub use atelier_json as json;

    #[cfg(feature = "openapi")]
    pub use atelier_openapi as openapi;

    #[cfg(feature = "smithy")]
    pub use atelier_smithy as smithy;
}

///
/// This module provides functions that wrap common actions into single entry points.
///
pub mod action {
    use atelier_core::action::lint::{run_linter_actions, NamingConventions};
    use atelier_core::action::validate::{
        run_validation_actions, CorrectTypeReferences, NoOrphanedReferences,
    };
    use atelier_core::action::ActionIssue;
    use atelier_core::model::Model;

    ///
    /// Execute all the standard model lint actions.
    ///
    pub fn standard_model_lint(model: &Model, fail_fast: bool) -> Option<Vec<ActionIssue>> {
        run_linter_actions(&[Box::new(NamingConventions::default())], model, fail_fast)
    }

    ///
    /// Execute all the standard model validation actions.
    ///
    pub fn standard_model_validation(model: &Model, fail_fast: bool) -> Option<Vec<ActionIssue>> {
        run_validation_actions(
            &[
                Box::new(NoOrphanedReferences::default()),
                Box::new(CorrectTypeReferences::default()),
            ],
            model,
            fail_fast,
        )
    }
}