Skip to content

Commit

Permalink
update source schema
Browse files Browse the repository at this point in the history
  • Loading branch information
chriskapp committed Sep 23, 2023
1 parent 9cbb301 commit 0014e3a
Show file tree
Hide file tree
Showing 16 changed files with 2,159 additions and 2,732 deletions.
196 changes: 77 additions & 119 deletions tests/Generator/resource/csharp/csharp_complex.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,47 +20,12 @@ public class CommonType
using System.Text.Json.Serialization;

/// <summary>
/// Represents a struct type. A struct type contains a fix set of defined properties
/// </summary>
public class StructType extends CommonType
{
[JsonPropertyName("$final")]
public bool Final { get; set; }
[JsonPropertyName("$extends")]
public string Extends { get; set; }
[JsonPropertyName("type")]
public string Type { get; set; }
[JsonPropertyName("properties")]
public Properties Properties { get; set; }
[JsonPropertyName("required")]
public string[] Required { get; set; }
}

using System.Text.Json.Serialization;
using System.Collections.Generic;

/// <summary>
/// Properties of a struct
/// </summary>
public class Properties : Dictionary<string, object>
{
}

using System.Text.Json.Serialization;

/// <summary>
/// Represents a map type. A map type contains variable key value entries of a specific type
/// Represents an any type
/// </summary>
public class MapType extends CommonType
public class AnyType extends CommonType
{
[JsonPropertyName("type")]
public string Type { get; set; }
[JsonPropertyName("additionalProperties")]
public object AdditionalProperties { get; set; }
[JsonPropertyName("maxProperties")]
public int MaxProperties { get; set; }
[JsonPropertyName("minProperties")]
public int MinProperties { get; set; }
}

using System.Text.Json.Serialization;
Expand Down Expand Up @@ -107,52 +72,28 @@ public class BooleanType extends ScalarType
}

using System.Text.Json.Serialization;
using System.Collections.Generic;

/// <summary>
/// Represents a number type (contains also integer)
/// </summary>
public class NumberType extends ScalarType
{
[JsonPropertyName("type")]
public string Type { get; set; }
[JsonPropertyName("multipleOf")]
public float MultipleOf { get; set; }
[JsonPropertyName("maximum")]
public float Maximum { get; set; }
[JsonPropertyName("exclusiveMaximum")]
public bool ExclusiveMaximum { get; set; }
[JsonPropertyName("minimum")]
public float Minimum { get; set; }
[JsonPropertyName("exclusiveMinimum")]
public bool ExclusiveMinimum { get; set; }
}

using System.Text.Json.Serialization;

/// <summary>
/// Represents a string type
/// Adds support for polymorphism. The discriminator is an object name that is used to differentiate between other schemas which may satisfy the payload description
/// </summary>
public class StringType extends ScalarType
public class Discriminator
{
[JsonPropertyName("type")]
public string Type { get; set; }
[JsonPropertyName("maxLength")]
public int MaxLength { get; set; }
[JsonPropertyName("minLength")]
public int MinLength { get; set; }
[JsonPropertyName("pattern")]
public string Pattern { get; set; }
[JsonPropertyName("propertyName")]
public string PropertyName { get; set; }
[JsonPropertyName("mapping")]
public Dictionary<string, string> Mapping { get; set; }
}

using System.Text.Json.Serialization;

/// <summary>
/// Represents an any type
/// Represents a generic type. A generic type can be used i.e. at a map or array which then can be replaced on reference via the $template keyword
/// </summary>
public class AnyType extends CommonType
public class GenericType
{
[JsonPropertyName("type")]
public string Type { get; set; }
[JsonPropertyName("$generic")]
public string Generic { get; set; }
}

using System.Text.Json.Serialization;
Expand All @@ -171,42 +112,43 @@ public class IntersectionType
using System.Text.Json.Serialization;

/// <summary>
/// Represents an union type. An union type can contain one of the provided types
/// </summary>
public class UnionType
{
[JsonPropertyName("description")]
public string Description { get; set; }
[JsonPropertyName("discriminator")]
public Discriminator Discriminator { get; set; }
[JsonPropertyName("oneOf")]
public object[] OneOf { get; set; }
}

using System.Text.Json.Serialization;
using System.Collections.Generic;

/// <summary>
/// An object to hold mappings between payload values and schema names or references
/// Represents a map type. A map type contains variable key value entries of a specific type
/// </summary>
public class DiscriminatorMapping : Dictionary<string, string>
public class MapType extends CommonType
{
[JsonPropertyName("type")]
public string Type { get; set; }
[JsonPropertyName("additionalProperties")]
public object AdditionalProperties { get; set; }
[JsonPropertyName("maxProperties")]
public int MaxProperties { get; set; }
[JsonPropertyName("minProperties")]
public int MinProperties { get; set; }
}

using System.Text.Json.Serialization;

/// <summary>
/// Adds support for polymorphism. The discriminator is an object name that is used to differentiate between other schemas which may satisfy the payload description
/// Represents a number type (contains also integer)
/// </summary>
public class Discriminator
public class NumberType extends ScalarType
{
[JsonPropertyName("propertyName")]
public string PropertyName { get; set; }
[JsonPropertyName("mapping")]
public DiscriminatorMapping Mapping { get; set; }
[JsonPropertyName("type")]
public string Type { get; set; }
[JsonPropertyName("multipleOf")]
public float MultipleOf { get; set; }
[JsonPropertyName("maximum")]
public float Maximum { get; set; }
[JsonPropertyName("exclusiveMaximum")]
public bool ExclusiveMaximum { get; set; }
[JsonPropertyName("minimum")]
public float Minimum { get; set; }
[JsonPropertyName("exclusiveMinimum")]
public bool ExclusiveMinimum { get; set; }
}

using System.Text.Json.Serialization;
using System.Collections.Generic;

/// <summary>
/// Represents a reference type. A reference type points to a specific type at the definitions map
Expand All @@ -216,57 +158,73 @@ public class ReferenceType
[JsonPropertyName("$ref")]
public string Ref { get; set; }
[JsonPropertyName("$template")]
public TemplateProperties Template { get; set; }
}

using System.Text.Json.Serialization;
using System.Collections.Generic;
public class TemplateProperties : Dictionary<string, string>
{
public Dictionary<string, string> Template { get; set; }
}

using System.Text.Json.Serialization;

/// <summary>
/// Represents a generic type. A generic type can be used i.e. at a map or array which then can be replaced on reference via the $template keyword
/// Represents a string type
/// </summary>
public class GenericType
public class StringType extends ScalarType
{
[JsonPropertyName("$generic")]
public string Generic { get; set; }
[JsonPropertyName("type")]
public string Type { get; set; }
[JsonPropertyName("maxLength")]
public int MaxLength { get; set; }
[JsonPropertyName("minLength")]
public int MinLength { get; set; }
[JsonPropertyName("pattern")]
public string Pattern { get; set; }
}

using System.Text.Json.Serialization;
using System.Collections.Generic;

/// <summary>
/// The definitions map which contains all types
/// Represents a struct type. A struct type contains a fix set of defined properties
/// </summary>
public class Definitions : Dictionary<string, object>
public class StructType extends CommonType
{
[JsonPropertyName("$final")]
public bool Final { get; set; }
[JsonPropertyName("$extends")]
public string Extends { get; set; }
[JsonPropertyName("type")]
public string Type { get; set; }
[JsonPropertyName("properties")]
public Dictionary<string, object> Properties { get; set; }
[JsonPropertyName("required")]
public string[] Required { get; set; }
}

using System.Text.Json.Serialization;
using System.Collections.Generic;

/// <summary>
/// Contains external definitions which are imported. The imported schemas can be used via the namespace i.e. 'my_namespace:my_type'
/// The root TypeSchema
/// </summary>
public class Import : Dictionary<string, string>
public class TypeSchema
{
[JsonPropertyName("$import")]
public Dictionary<string, string> Import { get; set; }
[JsonPropertyName("definitions")]
public Dictionary<string, object> Definitions { get; set; }
[JsonPropertyName("$ref")]
public string Ref { get; set; }
}

using System.Text.Json.Serialization;

/// <summary>
/// The root TypeSchema
/// Represents an union type. An union type can contain one of the provided types
/// </summary>
public class TypeSchema
public class UnionType
{
[JsonPropertyName("$import")]
public Import Import { get; set; }
[JsonPropertyName("definitions")]
public Definitions Definitions { get; set; }
[JsonPropertyName("$ref")]
public string Ref { get; set; }
[JsonPropertyName("description")]
public string Description { get; set; }
[JsonPropertyName("discriminator")]
public Discriminator Discriminator { get; set; }
[JsonPropertyName("oneOf")]
public object[] OneOf { get; set; }
}
Loading

0 comments on commit 0014e3a

Please sign in to comment.