Skip to content
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
42 changes: 42 additions & 0 deletions Cargo.lock

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

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,6 @@ jsonschema = "0.18"

# File system
walkdir = "2.5"

# Format parsing
serde_yaml = "0.9"
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ Other features:
- [x] **Web server** - a non-production web-server with REST API for the operations processing and testing
- [x] **CLI** - command-line interface for all GTS operations
- [ ] **UUID for instances** - to support UUID as ID in JSON instances
- [x] **YAML support** - to support YAML files (*.yml, *.yaml) as input files
- [ ] **TypeSpec support** - Add [typespec.io](https://typespec.io/) files (*.tsp) support

Technical Backlog:
Expand Down
1 change: 1 addition & 0 deletions gts/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@ jsonschema.workspace = true
walkdir.workspace = true
tracing.workspace = true
shellexpand = "3.1"
serde_yaml.workspace = true

[dev-dependencies]
26 changes: 13 additions & 13 deletions gts/src/entities.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::collections::HashMap;

use crate::gts::GtsID;
use crate::path_resolver::JsonPathResolver;
use crate::schema_cast::{JsonEntityCastResult, SchemaCastError};
use crate::schema_cast::{GtsEntityCastResult, SchemaCastError};

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ValidationError {
Expand All @@ -25,7 +25,7 @@ pub struct ValidationResult {
}

#[derive(Debug, Clone)]
pub struct JsonFile {
pub struct GtsFile {
pub path: String,
pub name: String,
pub content: Value,
Expand All @@ -34,7 +34,7 @@ pub struct JsonFile {
pub validation: ValidationResult,
}

impl JsonFile {
impl GtsFile {
pub fn new(path: String, name: String, content: Value) -> Self {
let mut sequences_count = 0;
let mut sequence_content = HashMap::new();
Expand All @@ -50,7 +50,7 @@ impl JsonFile {
sequence_content.insert(i, item.clone());
}

JsonFile {
GtsFile {
path,
name,
content,
Expand Down Expand Up @@ -103,10 +103,10 @@ pub struct GtsRef {
}

#[derive(Debug, Clone)]
pub struct JsonEntity {
pub struct GtsEntity {
pub gts_id: Option<GtsID>,
pub is_schema: bool,
pub file: Option<JsonFile>,
pub file: Option<GtsFile>,
pub list_sequence: Option<usize>,
pub label: String,
pub content: Value,
Expand All @@ -119,9 +119,9 @@ pub struct JsonEntity {
pub schema_refs: Vec<GtsRef>,
}

impl JsonEntity {
impl GtsEntity {
pub fn new(
file: Option<JsonFile>,
file: Option<GtsFile>,
list_sequence: Option<usize>,
content: Value,
cfg: Option<&GtsConfig>,
Expand All @@ -131,7 +131,7 @@ impl JsonEntity {
validation: Option<ValidationResult>,
schema_id: Option<String>,
) -> Self {
let mut entity = JsonEntity {
let mut entity = GtsEntity {
file,
list_sequence,
content: content.clone(),
Expand Down Expand Up @@ -226,10 +226,10 @@ impl JsonEntity {

pub fn cast(
&self,
to_schema: &JsonEntity,
from_schema: &JsonEntity,
to_schema: &GtsEntity,
from_schema: &GtsEntity,
resolver: Option<&()>,
) -> Result<JsonEntityCastResult, SchemaCastError> {
) -> Result<GtsEntityCastResult, SchemaCastError> {
if self.is_schema {
// When casting a schema, from_schema might be a standard JSON Schema (no gts_id)
if let (Some(ref self_id), Some(ref from_id)) = (&self.gts_id, &from_schema.gts_id) {
Expand Down Expand Up @@ -261,7 +261,7 @@ impl JsonEntity {
.map(|g| g.id.clone())
.unwrap_or_default();

JsonEntityCastResult::cast(
GtsEntityCastResult::cast(
&from_id,
&to_id,
&self.content,
Expand Down
Loading