From e69fae6edae07b5adc931a4172126f83042028f1 Mon Sep 17 00:00:00 2001 From: Christoph Kappestein <christoph.kappestein@gmail.com> Date: Sun, 17 Nov 2024 22:03:45 +0100 Subject: [PATCH] update complex schema --- src/Generator/CSharp.php | 33 +- .../complex/CollectionDefinitionType.cs | 5 +- .../csharp/complex/CollectionPropertyType.cs | 6 + .../resource/csharp/complex/DefinitionType.cs | 10 +- .../resource/csharp/complex/PropertyType.cs | 24 +- .../csharp/complex/ScalarPropertyType.cs | 7 +- .../csharp/complex/StructDefinitionType.cs | 12 +- .../resource/csharp/complex/TypeSchema.cs | 6 +- .../resource/go/complex/any_property_type.go | 4 +- .../go/complex/array_definition_type.go | 4 +- .../go/complex/array_property_type.go | 4 +- .../go/complex/boolean_property_type.go | 2 +- .../go/complex/collection_definition_type.go | 2 +- .../go/complex/collection_property_type.go | 4 +- .../resource/go/complex/definition_type.go | 2 +- .../go/complex/generic_property_type.go | 4 +- .../go/complex/integer_property_type.go | 2 +- .../go/complex/map_definition_type.go | 2 +- .../resource/go/complex/map_property_type.go | 4 +- .../go/complex/number_property_type.go | 2 +- .../resource/go/complex/property_type.go | 4 +- .../go/complex/reference_property_type.go | 4 +- .../go/complex/scalar_property_type.go | 4 +- .../go/complex/string_property_type.go | 4 +- .../go/complex/struct_definition_type.go | 6 +- .../resource/go/complex/type_schema.go | 2 +- .../Generator/resource/html/html_complex.htm | 151 ++---- .../complex/CollectionDefinitionType.java | 13 +- .../java/complex/CollectionPropertyType.java | 16 + .../resource/java/complex/DefinitionType.java | 26 +- .../resource/java/complex/PropertyType.java | 56 +-- .../java/complex/ScalarPropertyType.java | 15 +- .../java/complex/StructDefinitionType.java | 44 +- .../resource/java/complex/TypeSchema.java | 22 +- .../jsonschema/jsonschema_complex.json | 308 +++--------- .../complex/CollectionDefinitionType.kt | 1 + .../kotlin/complex/CollectionPropertyType.kt | 1 + .../resource/kotlin/complex/DefinitionType.kt | 2 +- .../resource/kotlin/complex/PropertyType.kt | 4 +- .../kotlin/complex/ScalarPropertyType.kt | 1 + .../kotlin/complex/StructDefinitionType.kt | 4 +- .../resource/kotlin/complex/TypeSchema.kt | 2 +- .../resource/markdown/markdown_complex.md | 181 ++----- .../php/complex/CollectionDefinitionType.php | 13 +- .../php/complex/CollectionPropertyType.php | 16 + .../resource/php/complex/DefinitionType.php | 27 +- .../resource/php/complex/PropertyType.php | 56 ++- .../php/complex/ScalarPropertyType.php | 25 +- .../php/complex/StructDefinitionType.php | 62 +-- .../resource/php/complex/TypeSchema.php | 35 +- .../complex/collection_definition_type.py | 17 +- .../complex/collection_property_type.py | 17 +- .../python/complex/definition_type.py | 6 +- .../resource/python/complex/property_type.py | 16 +- .../python/complex/scalar_property_type.py | 5 +- .../python/complex/struct_definition_type.py | 4 +- .../resource/python/complex/type_schema.py | 2 +- .../complex/collection_definition_type.rb | 5 +- .../ruby/complex/collection_property_type.rb | 5 +- .../resource/ruby/complex/definition_type.rb | 6 +- .../resource/ruby/complex/property_type.rb | 8 +- .../ruby/complex/scalar_property_type.rb | 4 +- .../ruby/complex/struct_definition_type.rb | 8 +- .../resource/ruby/complex/type_schema.rb | 6 +- .../rust/complex/any_property_type.rs | 12 +- .../rust/complex/array_definition_type.rs | 8 +- .../rust/complex/array_property_type.rs | 10 +- .../rust/complex/boolean_property_type.rs | 6 +- .../complex/collection_definition_type.rs | 8 +- .../rust/complex/collection_property_type.rs | 14 +- .../resource/rust/complex/definition_type.rs | 10 +- .../rust/complex/generic_property_type.rs | 12 +- .../rust/complex/integer_property_type.rs | 6 +- .../rust/complex/map_definition_type.rs | 6 +- .../rust/complex/map_property_type.rs | 12 +- .../rust/complex/number_property_type.rs | 6 +- .../resource/rust/complex/property_type.rs | 24 +- .../rust/complex/reference_property_type.rs | 12 +- .../rust/complex/scalar_property_type.rs | 16 +- .../rust/complex/string_property_type.rs | 12 +- .../rust/complex/struct_definition_type.rs | 18 +- .../resource/rust/complex/type_schema.rs | 6 +- .../Generator/resource/source_typeschema.json | 462 ++++++------------ .../complex/CollectionDefinitionType.swift | 2 + .../complex/CollectionPropertyType.swift | 2 + .../swift/complex/DefinitionType.swift | 4 +- .../resource/swift/complex/PropertyType.swift | 8 +- .../swift/complex/ScalarPropertyType.swift | 2 + .../swift/complex/StructDefinitionType.swift | 8 +- .../resource/swift/complex/TypeSchema.swift | 4 +- .../typeschema/typeschema_complex.json | 297 +++-------- .../complex/CollectionDefinitionType.ts | 3 +- .../complex/CollectionPropertyType.ts | 3 + .../typescript/complex/DefinitionType.ts | 6 +- .../typescript/complex/PropertyType.ts | 16 +- .../typescript/complex/ScalarPropertyType.ts | 5 +- .../complex/StructDefinitionType.ts | 4 +- .../resource/typescript/complex/TypeSchema.ts | 2 +- .../complex/CollectionDefinitionType.vb | 3 + .../complex/CollectionPropertyType.vb | 3 + .../visualbasic/complex/DefinitionType.vb | 6 +- .../visualbasic/complex/PropertyType.vb | 12 +- .../visualbasic/complex/ScalarPropertyType.vb | 3 + .../complex/StructDefinitionType.vb | 12 +- .../visualbasic/complex/TypeSchema.vb | 6 +- 105 files changed, 963 insertions(+), 1461 deletions(-) diff --git a/src/Generator/CSharp.php b/src/Generator/CSharp.php index 1eacd82..134a484 100644 --- a/src/Generator/CSharp.php +++ b/src/Generator/CSharp.php @@ -20,11 +20,13 @@ namespace PSX\Schema\Generator; +use PSX\Schema\Exception\TypeNotFoundException; use PSX\Schema\Generator\Normalizer\NormalizerInterface; use PSX\Schema\Generator\Type\GeneratorInterface; use PSX\Schema\Type\ArrayDefinitionType; use PSX\Schema\Type\DefinitionTypeAbstract; use PSX\Schema\Type\MapDefinitionType; +use PSX\Schema\Type\ReferencePropertyType; use PSX\Schema\Type\StructDefinitionType; use PSX\Schema\TypeUtil; @@ -86,8 +88,15 @@ protected function writeStruct(Code\Name $name, array $properties, ?string $exte foreach ($properties as $property) { /** @var Code\Property $property */ + // in case we override an existing property we need to use the new keyword s. + // https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/new-modifier + $override = ''; + if ($this->hasPropertyInParent($property->getName()->getRaw(), $origin->getParent())) { + $override = 'new '; + } + $code.= $this->indent . '[JsonPropertyName("' . $property->getName()->getRaw() . '")]' . "\n"; - $code.= $this->indent . 'public ' . $property->getType() . '? ' . $property->getName()->getProperty() . ' { get; set; }' . "\n"; + $code.= $this->indent . 'public ' . $override . $property->getType() . '? ' . $property->getName()->getProperty() . ' { get; set; }' . "\n"; $code.= "\n"; } @@ -151,4 +160,26 @@ private function getImports(DefinitionTypeAbstract $origin): array return $imports; } + + /** + * @throws TypeNotFoundException + */ + private function hasPropertyInParent(string $propertyName, ?ReferencePropertyType $reference): bool + { + $target = $reference?->getTarget(); + if (empty($target)) { + return false; + } + + $parent = $this->definitions->getType($target); + if (!$parent instanceof StructDefinitionType) { + return false; + } + + if ($parent->hasProperty($propertyName)) { + return true; + } + + return $this->hasPropertyInParent($propertyName, $parent->getParent()); + } } diff --git a/tests/Generator/resource/csharp/complex/CollectionDefinitionType.cs b/tests/Generator/resource/csharp/complex/CollectionDefinitionType.cs index b398978..7f1fea8 100644 --- a/tests/Generator/resource/csharp/complex/CollectionDefinitionType.cs +++ b/tests/Generator/resource/csharp/complex/CollectionDefinitionType.cs @@ -6,12 +6,15 @@ namespace TypeAPI.Model; /// Base collection type /// </summary> [JsonPolymorphic(TypeDiscriminatorPropertyName = "type")] -[JsonDerivedType(typeof(MapDefinitionType), typeDiscriminator: "map")] [JsonDerivedType(typeof(ArrayDefinitionType), typeDiscriminator: "array")] +[JsonDerivedType(typeof(MapDefinitionType), typeDiscriminator: "map")] public abstract class CollectionDefinitionType : DefinitionType { [JsonPropertyName("schema")] public PropertyType? Schema { get; set; } + [JsonPropertyName("type")] + public new string? Type { get; set; } + } diff --git a/tests/Generator/resource/csharp/complex/CollectionPropertyType.cs b/tests/Generator/resource/csharp/complex/CollectionPropertyType.cs index 3e3e180..5ec2bb4 100644 --- a/tests/Generator/resource/csharp/complex/CollectionPropertyType.cs +++ b/tests/Generator/resource/csharp/complex/CollectionPropertyType.cs @@ -5,10 +5,16 @@ namespace TypeAPI.Model; /// <summary> /// Base collection property type /// </summary> +[JsonPolymorphic(TypeDiscriminatorPropertyName = "type")] +[JsonDerivedType(typeof(ArrayPropertyType), typeDiscriminator: "array")] +[JsonDerivedType(typeof(MapPropertyType), typeDiscriminator: "map")] public abstract class CollectionPropertyType : PropertyType { [JsonPropertyName("schema")] public PropertyType? Schema { get; set; } + [JsonPropertyName("type")] + public new string? Type { get; set; } + } diff --git a/tests/Generator/resource/csharp/complex/DefinitionType.cs b/tests/Generator/resource/csharp/complex/DefinitionType.cs index e1bd6df..bb1062f 100644 --- a/tests/Generator/resource/csharp/complex/DefinitionType.cs +++ b/tests/Generator/resource/csharp/complex/DefinitionType.cs @@ -6,19 +6,19 @@ namespace TypeAPI.Model; /// Base definition type /// </summary> [JsonPolymorphic(TypeDiscriminatorPropertyName = "type")] -[JsonDerivedType(typeof(StructDefinitionType), typeDiscriminator: "struct")] -[JsonDerivedType(typeof(MapDefinitionType), typeDiscriminator: "map")] [JsonDerivedType(typeof(ArrayDefinitionType), typeDiscriminator: "array")] +[JsonDerivedType(typeof(MapDefinitionType), typeDiscriminator: "map")] +[JsonDerivedType(typeof(StructDefinitionType), typeDiscriminator: "struct")] public abstract class DefinitionType { + [JsonPropertyName("deprecated")] + public bool? Deprecated { get; set; } + [JsonPropertyName("description")] public string? Description { get; set; } [JsonPropertyName("type")] public string? Type { get; set; } - [JsonPropertyName("deprecated")] - public bool? Deprecated { get; set; } - } diff --git a/tests/Generator/resource/csharp/complex/PropertyType.cs b/tests/Generator/resource/csharp/complex/PropertyType.cs index ce63b10..092e6bd 100644 --- a/tests/Generator/resource/csharp/complex/PropertyType.cs +++ b/tests/Generator/resource/csharp/complex/PropertyType.cs @@ -6,28 +6,28 @@ namespace TypeAPI.Model; /// Base property type /// </summary> [JsonPolymorphic(TypeDiscriminatorPropertyName = "type")] -[JsonDerivedType(typeof(StringPropertyType), typeDiscriminator: "string")] -[JsonDerivedType(typeof(IntegerPropertyType), typeDiscriminator: "integer")] -[JsonDerivedType(typeof(NumberPropertyType), typeDiscriminator: "number")] -[JsonDerivedType(typeof(BooleanPropertyType), typeDiscriminator: "boolean")] -[JsonDerivedType(typeof(MapPropertyType), typeDiscriminator: "map")] -[JsonDerivedType(typeof(ArrayPropertyType), typeDiscriminator: "array")] [JsonDerivedType(typeof(AnyPropertyType), typeDiscriminator: "any")] +[JsonDerivedType(typeof(ArrayPropertyType), typeDiscriminator: "array")] +[JsonDerivedType(typeof(BooleanPropertyType), typeDiscriminator: "boolean")] [JsonDerivedType(typeof(GenericPropertyType), typeDiscriminator: "generic")] +[JsonDerivedType(typeof(IntegerPropertyType), typeDiscriminator: "integer")] +[JsonDerivedType(typeof(MapPropertyType), typeDiscriminator: "map")] +[JsonDerivedType(typeof(NumberPropertyType), typeDiscriminator: "number")] [JsonDerivedType(typeof(ReferencePropertyType), typeDiscriminator: "reference")] +[JsonDerivedType(typeof(StringPropertyType), typeDiscriminator: "string")] public abstract class PropertyType { - [JsonPropertyName("description")] - public string? Description { get; set; } - - [JsonPropertyName("type")] - public string? Type { get; set; } - [JsonPropertyName("deprecated")] public bool? Deprecated { get; set; } + [JsonPropertyName("description")] + public string? Description { get; set; } + [JsonPropertyName("nullable")] public bool? Nullable { get; set; } + [JsonPropertyName("type")] + public string? Type { get; set; } + } diff --git a/tests/Generator/resource/csharp/complex/ScalarPropertyType.cs b/tests/Generator/resource/csharp/complex/ScalarPropertyType.cs index 937cf2c..09a226d 100644 --- a/tests/Generator/resource/csharp/complex/ScalarPropertyType.cs +++ b/tests/Generator/resource/csharp/complex/ScalarPropertyType.cs @@ -6,11 +6,14 @@ namespace TypeAPI.Model; /// Base scalar property type /// </summary> [JsonPolymorphic(TypeDiscriminatorPropertyName = "type")] -[JsonDerivedType(typeof(StringPropertyType), typeDiscriminator: "string")] +[JsonDerivedType(typeof(BooleanPropertyType), typeDiscriminator: "boolean")] [JsonDerivedType(typeof(IntegerPropertyType), typeDiscriminator: "integer")] [JsonDerivedType(typeof(NumberPropertyType), typeDiscriminator: "number")] -[JsonDerivedType(typeof(BooleanPropertyType), typeDiscriminator: "boolean")] +[JsonDerivedType(typeof(StringPropertyType), typeDiscriminator: "string")] public abstract class ScalarPropertyType : PropertyType { + [JsonPropertyName("type")] + public new string? Type { get; set; } + } diff --git a/tests/Generator/resource/csharp/complex/StructDefinitionType.cs b/tests/Generator/resource/csharp/complex/StructDefinitionType.cs index 9e7332e..556bd48 100644 --- a/tests/Generator/resource/csharp/complex/StructDefinitionType.cs +++ b/tests/Generator/resource/csharp/complex/StructDefinitionType.cs @@ -7,20 +7,20 @@ namespace TypeAPI.Model; /// </summary> public class StructDefinitionType : DefinitionType { - [JsonPropertyName("parent")] - public ReferencePropertyType? Parent { get; set; } - [JsonPropertyName("base")] public bool? Base { get; set; } - [JsonPropertyName("properties")] - public System.Collections.Generic.Dictionary<string, PropertyType>? Properties { get; set; } - [JsonPropertyName("discriminator")] public string? Discriminator { get; set; } [JsonPropertyName("mapping")] public System.Collections.Generic.Dictionary<string, string>? Mapping { get; set; } + [JsonPropertyName("parent")] + public ReferencePropertyType? Parent { get; set; } + + [JsonPropertyName("properties")] + public System.Collections.Generic.Dictionary<string, PropertyType>? Properties { get; set; } + } diff --git a/tests/Generator/resource/csharp/complex/TypeSchema.cs b/tests/Generator/resource/csharp/complex/TypeSchema.cs index 1588607..68cf839 100644 --- a/tests/Generator/resource/csharp/complex/TypeSchema.cs +++ b/tests/Generator/resource/csharp/complex/TypeSchema.cs @@ -7,12 +7,12 @@ namespace TypeAPI.Model; /// </summary> public class TypeSchema { - [JsonPropertyName("import")] - public System.Collections.Generic.Dictionary<string, string>? Import { get; set; } - [JsonPropertyName("definitions")] public System.Collections.Generic.Dictionary<string, DefinitionType>? Definitions { get; set; } + [JsonPropertyName("import")] + public System.Collections.Generic.Dictionary<string, string>? Import { get; set; } + [JsonPropertyName("root")] public string? Root { get; set; } diff --git a/tests/Generator/resource/go/complex/any_property_type.go b/tests/Generator/resource/go/complex/any_property_type.go index 84e83c7..d99cbd9 100644 --- a/tests/Generator/resource/go/complex/any_property_type.go +++ b/tests/Generator/resource/go/complex/any_property_type.go @@ -1,9 +1,9 @@ // Represents an any value which allows any kind of value type AnyPropertyType struct { - Description string `json:"description"` - Type string `json:"type"` Deprecated bool `json:"deprecated"` + Description string `json:"description"` Nullable bool `json:"nullable"` + Type string `json:"type"` } diff --git a/tests/Generator/resource/go/complex/array_definition_type.go b/tests/Generator/resource/go/complex/array_definition_type.go index 450b733..d0dcb35 100644 --- a/tests/Generator/resource/go/complex/array_definition_type.go +++ b/tests/Generator/resource/go/complex/array_definition_type.go @@ -1,9 +1,9 @@ // Represents an array which contains a dynamic list of values of the same type type ArrayDefinitionType struct { - Description string `json:"description"` + Schema *PropertyType `json:"schema"` Type string `json:"type"` Deprecated bool `json:"deprecated"` - Schema *PropertyType `json:"schema"` + Description string `json:"description"` } diff --git a/tests/Generator/resource/go/complex/array_property_type.go b/tests/Generator/resource/go/complex/array_property_type.go index 3c13691..bd6d057 100644 --- a/tests/Generator/resource/go/complex/array_property_type.go +++ b/tests/Generator/resource/go/complex/array_property_type.go @@ -1,10 +1,10 @@ // Represents an array which contains a dynamic list of values of the same type type ArrayPropertyType struct { - Description string `json:"description"` + Schema *PropertyType `json:"schema"` Type string `json:"type"` Deprecated bool `json:"deprecated"` + Description string `json:"description"` Nullable bool `json:"nullable"` - Schema *PropertyType `json:"schema"` } diff --git a/tests/Generator/resource/go/complex/boolean_property_type.go b/tests/Generator/resource/go/complex/boolean_property_type.go index 0ab2e52..0c018ec 100644 --- a/tests/Generator/resource/go/complex/boolean_property_type.go +++ b/tests/Generator/resource/go/complex/boolean_property_type.go @@ -1,9 +1,9 @@ // Represents a boolean value type BooleanPropertyType struct { - Description string `json:"description"` Type string `json:"type"` Deprecated bool `json:"deprecated"` + Description string `json:"description"` Nullable bool `json:"nullable"` } diff --git a/tests/Generator/resource/go/complex/collection_definition_type.go b/tests/Generator/resource/go/complex/collection_definition_type.go index b3cc005..ad72e95 100644 --- a/tests/Generator/resource/go/complex/collection_definition_type.go +++ b/tests/Generator/resource/go/complex/collection_definition_type.go @@ -1,9 +1,9 @@ // Base collection type type CollectionDefinitionType struct { + Deprecated bool `json:"deprecated"` Description string `json:"description"` Type string `json:"type"` - Deprecated bool `json:"deprecated"` Schema *PropertyType `json:"schema"` } diff --git a/tests/Generator/resource/go/complex/collection_property_type.go b/tests/Generator/resource/go/complex/collection_property_type.go index fc49c58..b89b8fc 100644 --- a/tests/Generator/resource/go/complex/collection_property_type.go +++ b/tests/Generator/resource/go/complex/collection_property_type.go @@ -1,10 +1,10 @@ // Base collection property type type CollectionPropertyType struct { - Description string `json:"description"` - Type string `json:"type"` Deprecated bool `json:"deprecated"` + Description string `json:"description"` Nullable bool `json:"nullable"` + Type string `json:"type"` Schema *PropertyType `json:"schema"` } diff --git a/tests/Generator/resource/go/complex/definition_type.go b/tests/Generator/resource/go/complex/definition_type.go index 69d54cc..6619ec4 100644 --- a/tests/Generator/resource/go/complex/definition_type.go +++ b/tests/Generator/resource/go/complex/definition_type.go @@ -1,8 +1,8 @@ // Base definition type type DefinitionType struct { + Deprecated bool `json:"deprecated"` Description string `json:"description"` Type string `json:"type"` - Deprecated bool `json:"deprecated"` } diff --git a/tests/Generator/resource/go/complex/generic_property_type.go b/tests/Generator/resource/go/complex/generic_property_type.go index 7b021e0..ea2fb48 100644 --- a/tests/Generator/resource/go/complex/generic_property_type.go +++ b/tests/Generator/resource/go/complex/generic_property_type.go @@ -1,10 +1,10 @@ // Represents a generic value which can be replaced with a dynamic type type GenericPropertyType struct { - Description string `json:"description"` - Type string `json:"type"` Deprecated bool `json:"deprecated"` + Description string `json:"description"` Nullable bool `json:"nullable"` + Type string `json:"type"` Name string `json:"name"` } diff --git a/tests/Generator/resource/go/complex/integer_property_type.go b/tests/Generator/resource/go/complex/integer_property_type.go index 0fac1ab..7ecab3f 100644 --- a/tests/Generator/resource/go/complex/integer_property_type.go +++ b/tests/Generator/resource/go/complex/integer_property_type.go @@ -1,9 +1,9 @@ // Represents an integer value type IntegerPropertyType struct { - Description string `json:"description"` Type string `json:"type"` Deprecated bool `json:"deprecated"` + Description string `json:"description"` Nullable bool `json:"nullable"` } diff --git a/tests/Generator/resource/go/complex/map_definition_type.go b/tests/Generator/resource/go/complex/map_definition_type.go index f20d7da..023f659 100644 --- a/tests/Generator/resource/go/complex/map_definition_type.go +++ b/tests/Generator/resource/go/complex/map_definition_type.go @@ -1,9 +1,9 @@ // Represents a map which contains a dynamic set of key value entries of the same type type MapDefinitionType struct { + Deprecated bool `json:"deprecated"` Description string `json:"description"` Type string `json:"type"` - Deprecated bool `json:"deprecated"` Schema *PropertyType `json:"schema"` } diff --git a/tests/Generator/resource/go/complex/map_property_type.go b/tests/Generator/resource/go/complex/map_property_type.go index 2450709..3091037 100644 --- a/tests/Generator/resource/go/complex/map_property_type.go +++ b/tests/Generator/resource/go/complex/map_property_type.go @@ -1,10 +1,10 @@ // Represents a map which contains a dynamic set of key value entries of the same type type MapPropertyType struct { - Description string `json:"description"` - Type string `json:"type"` Deprecated bool `json:"deprecated"` + Description string `json:"description"` Nullable bool `json:"nullable"` + Type string `json:"type"` Schema *PropertyType `json:"schema"` } diff --git a/tests/Generator/resource/go/complex/number_property_type.go b/tests/Generator/resource/go/complex/number_property_type.go index 35d8a06..0c265be 100644 --- a/tests/Generator/resource/go/complex/number_property_type.go +++ b/tests/Generator/resource/go/complex/number_property_type.go @@ -1,9 +1,9 @@ // Represents a float value type NumberPropertyType struct { - Description string `json:"description"` Type string `json:"type"` Deprecated bool `json:"deprecated"` + Description string `json:"description"` Nullable bool `json:"nullable"` } diff --git a/tests/Generator/resource/go/complex/property_type.go b/tests/Generator/resource/go/complex/property_type.go index 209ee56..0c4a439 100644 --- a/tests/Generator/resource/go/complex/property_type.go +++ b/tests/Generator/resource/go/complex/property_type.go @@ -1,9 +1,9 @@ // Base property type type PropertyType struct { - Description string `json:"description"` - Type string `json:"type"` Deprecated bool `json:"deprecated"` + Description string `json:"description"` Nullable bool `json:"nullable"` + Type string `json:"type"` } diff --git a/tests/Generator/resource/go/complex/reference_property_type.go b/tests/Generator/resource/go/complex/reference_property_type.go index 6718a9b..33aea8a 100644 --- a/tests/Generator/resource/go/complex/reference_property_type.go +++ b/tests/Generator/resource/go/complex/reference_property_type.go @@ -1,10 +1,10 @@ // Represents a reference to a definition type type ReferencePropertyType struct { - Description string `json:"description"` - Type string `json:"type"` Deprecated bool `json:"deprecated"` + Description string `json:"description"` Nullable bool `json:"nullable"` + Type string `json:"type"` Target string `json:"target"` Template map[string]string `json:"template"` } diff --git a/tests/Generator/resource/go/complex/scalar_property_type.go b/tests/Generator/resource/go/complex/scalar_property_type.go index d1ae062..1d66e24 100644 --- a/tests/Generator/resource/go/complex/scalar_property_type.go +++ b/tests/Generator/resource/go/complex/scalar_property_type.go @@ -1,9 +1,9 @@ // Base scalar property type type ScalarPropertyType struct { - Description string `json:"description"` - Type string `json:"type"` Deprecated bool `json:"deprecated"` + Description string `json:"description"` Nullable bool `json:"nullable"` + Type string `json:"type"` } diff --git a/tests/Generator/resource/go/complex/string_property_type.go b/tests/Generator/resource/go/complex/string_property_type.go index 45c42bc..ca61947 100644 --- a/tests/Generator/resource/go/complex/string_property_type.go +++ b/tests/Generator/resource/go/complex/string_property_type.go @@ -1,10 +1,10 @@ // Represents a string value type StringPropertyType struct { - Description string `json:"description"` - Type string `json:"type"` Deprecated bool `json:"deprecated"` + Description string `json:"description"` Nullable bool `json:"nullable"` + Type string `json:"type"` Format string `json:"format"` } diff --git a/tests/Generator/resource/go/complex/struct_definition_type.go b/tests/Generator/resource/go/complex/struct_definition_type.go index fe9b8cf..3233b46 100644 --- a/tests/Generator/resource/go/complex/struct_definition_type.go +++ b/tests/Generator/resource/go/complex/struct_definition_type.go @@ -1,13 +1,13 @@ // A struct represents a class/structure with a fix set of defined properties. type StructDefinitionType struct { + Deprecated bool `json:"deprecated"` Description string `json:"description"` Type string `json:"type"` - Deprecated bool `json:"deprecated"` - Parent *ReferencePropertyType `json:"parent"` Base bool `json:"base"` - Properties map[string]PropertyType `json:"properties"` Discriminator string `json:"discriminator"` Mapping map[string]string `json:"mapping"` + Parent *ReferencePropertyType `json:"parent"` + Properties map[string]PropertyType `json:"properties"` } diff --git a/tests/Generator/resource/go/complex/type_schema.go b/tests/Generator/resource/go/complex/type_schema.go index 4d89045..abf562a 100644 --- a/tests/Generator/resource/go/complex/type_schema.go +++ b/tests/Generator/resource/go/complex/type_schema.go @@ -1,8 +1,8 @@ // TypeSchema specification type TypeSchema struct { - Import map[string]string `json:"import"` Definitions map[string]DefinitionType `json:"definitions"` + Import map[string]string `json:"import"` Root string `json:"root"` } diff --git a/tests/Generator/resource/html/html_complex.htm b/tests/Generator/resource/html/html_complex.htm index b479985..db1dc69 100644 --- a/tests/Generator/resource/html/html_complex.htm +++ b/tests/Generator/resource/html/html_complex.htm @@ -1,150 +1,70 @@ -<div id="Security" class="psx-object psx-struct"><h1><a class="psx-type-link" data-name="Security">Security</a></h1><pre class="psx-object-json"><span class="psx-object-json-pun">{</span> +<div id="PropertyType" class="psx-object psx-struct"><h1><a class="psx-type-link" data-name="PropertyType">PropertyType</a></h1><div class="psx-object-description">Base property type</div><pre class="psx-object-json"><span class="psx-object-json-pun">{</span> + <span class="psx-object-json-key">"deprecated"</span><span class="psx-object-json-pun">: </span><span class="psx-property-type">Boolean</span><span class="psx-object-json-pun">,</span> + <span class="psx-object-json-key">"description"</span><span class="psx-object-json-pun">: </span><span class="psx-property-type">String</span><span class="psx-object-json-pun">,</span> + <span class="psx-object-json-key">"nullable"</span><span class="psx-object-json-pun">: </span><span class="psx-property-type">Boolean</span><span class="psx-object-json-pun">,</span> <span class="psx-object-json-key">"type"</span><span class="psx-object-json-pun">: </span><span class="psx-property-type">String</span><span class="psx-object-json-pun">,</span> -<span class="psx-object-json-pun">}</span></pre><table class="table psx-object-properties"><colgroup><col width="30%" /><col width="70%" /></colgroup><thead><tr><th>Field</th><th>Description</th></tr></thead><tbody><tr><td><span class="psx-property-name ">type</span></td><td><span class="psx-property-type"><a class="psx-type-link" data-name="String">String</a></span><br /><div class="psx-property-description">The global security type of the API must be one of: httpBasic, httpBearer, apiKey or oauth2</div></td></tr></tbody></table></div> - - -<div id="SecurityHttpBasic" class="psx-object psx-struct"><h1><a class="psx-type-link" data-name="SecurityHttpBasic">SecurityHttpBasic</a> extends <a class="psx-type-link" data-name="Security">Security</a></h1><pre class="psx-object-json"><span class="psx-object-json-pun">{</span> -<span class="psx-object-json-pun">}</span></pre><table class="table psx-object-properties"><colgroup><col width="30%" /><col width="70%" /></colgroup><thead><tr><th>Field</th><th>Description</th></tr></thead><tbody></tbody></table></div> +<span class="psx-object-json-pun">}</span></pre><table class="table psx-object-properties"><colgroup><col width="30%" /><col width="70%" /></colgroup><thead><tr><th>Field</th><th>Description</th></tr></thead><tbody><tr><td><span class="psx-property-name ">deprecated</span></td><td><span class="psx-property-type"><a class="psx-type-link" data-name="Boolean">Boolean</a></span><br /><div class="psx-property-description"></div></td></tr><tr><td><span class="psx-property-name ">description</span></td><td><span class="psx-property-type"><a class="psx-type-link" data-name="String">String</a></span><br /><div class="psx-property-description"></div></td></tr><tr><td><span class="psx-property-name ">nullable</span></td><td><span class="psx-property-type"><a class="psx-type-link" data-name="Boolean">Boolean</a></span><br /><div class="psx-property-description"></div></td></tr><tr><td><span class="psx-property-name ">type</span></td><td><span class="psx-property-type"><a class="psx-type-link" data-name="String">String</a></span><br /><div class="psx-property-description"></div></td></tr></tbody></table></div> -<div id="SecurityHttpBearer" class="psx-object psx-struct"><h1><a class="psx-type-link" data-name="SecurityHttpBearer">SecurityHttpBearer</a> extends <a class="psx-type-link" data-name="Security">Security</a></h1><pre class="psx-object-json"><span class="psx-object-json-pun">{</span> +<div id="AnyPropertyType" class="psx-object psx-struct"><h1><a class="psx-type-link" data-name="AnyPropertyType">AnyPropertyType</a> extends <a class="psx-type-link" data-name="PropertyType">PropertyType</a></h1><div class="psx-object-description">Represents an any value which allows any kind of value</div><pre class="psx-object-json"><span class="psx-object-json-pun">{</span> <span class="psx-object-json-pun">}</span></pre><table class="table psx-object-properties"><colgroup><col width="30%" /><col width="70%" /></colgroup><thead><tr><th>Field</th><th>Description</th></tr></thead><tbody></tbody></table></div> -<div id="SecurityApiKey" class="psx-object psx-struct"><h1><a class="psx-type-link" data-name="SecurityApiKey">SecurityApiKey</a> extends <a class="psx-type-link" data-name="Security">Security</a></h1><pre class="psx-object-json"><span class="psx-object-json-pun">{</span> - <span class="psx-object-json-key">"name"</span><span class="psx-object-json-pun">: </span><span class="psx-property-type">String</span><span class="psx-object-json-pun">,</span> - <span class="psx-object-json-key">"in"</span><span class="psx-object-json-pun">: </span><span class="psx-property-type">String</span><span class="psx-object-json-pun">,</span> -<span class="psx-object-json-pun">}</span></pre><table class="table psx-object-properties"><colgroup><col width="30%" /><col width="70%" /></colgroup><thead><tr><th>Field</th><th>Description</th></tr></thead><tbody><tr><td><span class="psx-property-name ">name</span></td><td><span class="psx-property-type"><a class="psx-type-link" data-name="String">String</a></span><br /><div class="psx-property-description">The name of the header or query parameter i.e. "X-Api-Key"</div></td></tr><tr><td><span class="psx-property-name ">in</span></td><td><span class="psx-property-type"><a class="psx-type-link" data-name="String">String</a></span><br /><div class="psx-property-description">Must be either "header" or "query"</div></td></tr></tbody></table></div> - - -<div id="SecurityOAuth" class="psx-object psx-struct"><h1><a class="psx-type-link" data-name="SecurityOAuth">SecurityOAuth</a> extends <a class="psx-type-link" data-name="Security">Security</a></h1><pre class="psx-object-json"><span class="psx-object-json-pun">{</span> - <span class="psx-object-json-key">"tokenUrl"</span><span class="psx-object-json-pun">: </span><span class="psx-property-type">String</span><span class="psx-object-json-pun">,</span> - <span class="psx-object-json-key">"authorizationUrl"</span><span class="psx-object-json-pun">: </span><span class="psx-property-type">String</span><span class="psx-object-json-pun">,</span> - <span class="psx-object-json-key">"scopes"</span><span class="psx-object-json-pun">: </span><span class="psx-property-type">Array (String)</span><span class="psx-object-json-pun">,</span> -<span class="psx-object-json-pun">}</span></pre><table class="table psx-object-properties"><colgroup><col width="30%" /><col width="70%" /></colgroup><thead><tr><th>Field</th><th>Description</th></tr></thead><tbody><tr><td><span class="psx-property-name ">tokenUrl</span></td><td><span class="psx-property-type"><a class="psx-type-link" data-name="String">String</a></span><br /><div class="psx-property-description">The OAuth2 token endpoint</div></td></tr><tr><td><span class="psx-property-name ">authorizationUrl</span></td><td><span class="psx-property-type"><a class="psx-type-link" data-name="String">String</a></span><br /><div class="psx-property-description">Optional the OAuth2 authorization endpoint</div></td></tr><tr><td><span class="psx-property-name ">scopes</span></td><td><span class="psx-property-type"><a class="psx-type-link" data-name="Array (String)">Array (String)</a></span><br /><div class="psx-property-description">Optional OAuth2 scopes</div></td></tr></tbody></table></div> - - -<div id="Operation" class="psx-object psx-struct"><h1><a class="psx-type-link" data-name="Operation">Operation</a></h1><pre class="psx-object-json"><span class="psx-object-json-pun">{</span> - <span class="psx-object-json-key">"method"</span><span class="psx-object-json-pun">: </span><span class="psx-property-type">String</span><span class="psx-object-json-pun">,</span> - <span class="psx-object-json-key">"path"</span><span class="psx-object-json-pun">: </span><span class="psx-property-type">String</span><span class="psx-object-json-pun">,</span> - <span class="psx-object-json-key">"return"</span><span class="psx-object-json-pun">: </span><span class="psx-property-type">Response</span><span class="psx-object-json-pun">,</span> - <span class="psx-object-json-key">"arguments"</span><span class="psx-object-json-pun">: </span><span class="psx-property-type">Map (Argument)</span><span class="psx-object-json-pun">,</span> - <span class="psx-object-json-key">"throws"</span><span class="psx-object-json-pun">: </span><span class="psx-property-type">Array (Response)</span><span class="psx-object-json-pun">,</span> - <span class="psx-object-json-key">"description"</span><span class="psx-object-json-pun">: </span><span class="psx-property-type">String</span><span class="psx-object-json-pun">,</span> - <span class="psx-object-json-key">"stability"</span><span class="psx-object-json-pun">: </span><span class="psx-property-type">Integer</span><span class="psx-object-json-pun">,</span> - <span class="psx-object-json-key">"security"</span><span class="psx-object-json-pun">: </span><span class="psx-property-type">Array (String)</span><span class="psx-object-json-pun">,</span> - <span class="psx-object-json-key">"authorization"</span><span class="psx-object-json-pun">: </span><span class="psx-property-type">Boolean</span><span class="psx-object-json-pun">,</span> - <span class="psx-object-json-key">"tags"</span><span class="psx-object-json-pun">: </span><span class="psx-property-type">Array (String)</span><span class="psx-object-json-pun">,</span> -<span class="psx-object-json-pun">}</span></pre><table class="table psx-object-properties"><colgroup><col width="30%" /><col width="70%" /></colgroup><thead><tr><th>Field</th><th>Description</th></tr></thead><tbody><tr><td><span class="psx-property-name ">method</span></td><td><span class="psx-property-type"><a class="psx-type-link" data-name="String">String</a></span><br /><div class="psx-property-description">The HTTP method which is associated with this operation, must be a valid HTTP method i.e. GET, POST, PUT etc.</div></td></tr><tr><td><span class="psx-property-name ">path</span></td><td><span class="psx-property-type"><a class="psx-type-link" data-name="String">String</a></span><br /><div class="psx-property-description">The HTTP path which is associated with this operation. A path can also include variable path fragments i.e. /my/path/:year then you can map the variable year path fragment to a specific argument</div></td></tr><tr><td><span class="psx-property-name ">return</span></td><td><span class="psx-property-type"><a class="psx-type-link" data-name="Response">Response</a></span><br /><div class="psx-property-description">The return type of this operation. The return has also an assigned HTTP success status code which is by default 200</div></td></tr><tr><td><span class="psx-property-name ">arguments</span></td><td><span class="psx-property-type"><a class="psx-type-link" data-name="Map (Argument)">Map (Argument)</a></span><br /><div class="psx-property-description">All arguments provided to this operation. Each argument is mapped to a location from the HTTP request i.e. query or body</div></td></tr><tr><td><span class="psx-property-name ">throws</span></td><td><span class="psx-property-type"><a class="psx-type-link" data-name="Array (Response)">Array (Response)</a></span><br /><div class="psx-property-description">All exceptional states which can occur in case the operation fails. Each exception is assigned to an HTTP error status code</div></td></tr><tr><td><span class="psx-property-name ">description</span></td><td><span class="psx-property-type"><a class="psx-type-link" data-name="String">String</a></span><br /><div class="psx-property-description">A short description of this operation. The generated code will include this description at the method so it is recommend to use simple alphanumeric characters and no new lines</div></td></tr><tr><td><span class="psx-property-name ">stability</span></td><td><span class="psx-property-type"><a class="psx-type-link" data-name="Integer">Integer</a></span><br /><div class="psx-property-description">Indicates the stability of this operation: 0 - Deprecated, 1 - Experimental, 2 - Stable, 3 - Legacy. If not explicit provided the operation is by default experimental.</div></td></tr><tr><td><span class="psx-property-name ">security</span></td><td><span class="psx-property-type"><a class="psx-type-link" data-name="Array (String)">Array (String)</a></span><br /><div class="psx-property-description">An array of scopes which are required to access this operation</div></td></tr><tr><td><span class="psx-property-name ">authorization</span></td><td><span class="psx-property-type"><a class="psx-type-link" data-name="Boolean">Boolean</a></span><br /><div class="psx-property-description">Indicates whether this operation needs authorization, if set to false the client will not send an authorization header, default it is true</div></td></tr><tr><td><span class="psx-property-name ">tags</span></td><td><span class="psx-property-type"><a class="psx-type-link" data-name="Array (String)">Array (String)</a></span><br /><div class="psx-property-description">Optional an array of tags to group operations</div></td></tr></tbody></table></div> - - -<div id="Argument" class="psx-object psx-struct"><h1><a class="psx-type-link" data-name="Argument">Argument</a></h1><pre class="psx-object-json"><span class="psx-object-json-pun">{</span> - <span class="psx-object-json-key">"in"</span><span class="psx-object-json-pun">: </span><span class="psx-property-type">String</span><span class="psx-object-json-pun">,</span> - <span class="psx-object-json-key">"schema"</span><span class="psx-object-json-pun">: </span><span class="psx-property-type">PropertyType</span><span class="psx-object-json-pun">,</span> - <span class="psx-object-json-key">"contentType"</span><span class="psx-object-json-pun">: </span><span class="psx-property-type">String</span><span class="psx-object-json-pun">,</span> - <span class="psx-object-json-key">"name"</span><span class="psx-object-json-pun">: </span><span class="psx-property-type">String</span><span class="psx-object-json-pun">,</span> -<span class="psx-object-json-pun">}</span></pre><table class="table psx-object-properties"><colgroup><col width="30%" /><col width="70%" /></colgroup><thead><tr><th>Field</th><th>Description</th></tr></thead><tbody><tr><td><span class="psx-property-name ">in</span></td><td><span class="psx-property-type"><a class="psx-type-link" data-name="String">String</a></span><br /><div class="psx-property-description">The location where the value can be found either in the path, query, header or body. If you choose path, then your path must have a fitting variable path fragment</div></td></tr><tr><td><span class="psx-property-name ">schema</span></td><td><span class="psx-property-type"><a class="psx-type-link" data-name="PropertyType">PropertyType</a></span><br /><div class="psx-property-description"></div></td></tr><tr><td><span class="psx-property-name ">contentType</span></td><td><span class="psx-property-type"><a class="psx-type-link" data-name="String">String</a></span><br /><div class="psx-property-description">In case the data is not a JSON payload which you can describe with a schema you can select a content type</div></td></tr><tr><td><span class="psx-property-name ">name</span></td><td><span class="psx-property-type"><a class="psx-type-link" data-name="String">String</a></span><br /><div class="psx-property-description">Optional the actual path, query or header name. If not provided the key of the argument map is used</div></td></tr></tbody></table></div> - - -<div id="Response" class="psx-object psx-struct"><h1><a class="psx-type-link" data-name="Response">Response</a></h1><pre class="psx-object-json"><span class="psx-object-json-pun">{</span> - <span class="psx-object-json-key">"code"</span><span class="psx-object-json-pun">: </span><span class="psx-property-type">Integer</span><span class="psx-object-json-pun">,</span> - <span class="psx-object-json-key">"contentType"</span><span class="psx-object-json-pun">: </span><span class="psx-property-type">String</span><span class="psx-object-json-pun">,</span> - <span class="psx-object-json-key">"schema"</span><span class="psx-object-json-pun">: </span><span class="psx-property-type">PropertyType</span><span class="psx-object-json-pun">,</span> -<span class="psx-object-json-pun">}</span></pre><table class="table psx-object-properties"><colgroup><col width="30%" /><col width="70%" /></colgroup><thead><tr><th>Field</th><th>Description</th></tr></thead><tbody><tr><td><span class="psx-property-name ">code</span></td><td><span class="psx-property-type"><a class="psx-type-link" data-name="Integer">Integer</a></span><br /><div class="psx-property-description">The associated HTTP response code. For error responses it is possible to use the 499, 599 or 999 status code to catch all errors</div></td></tr><tr><td><span class="psx-property-name ">contentType</span></td><td><span class="psx-property-type"><a class="psx-type-link" data-name="String">String</a></span><br /><div class="psx-property-description">In case the data is not a JSON payload which you can describe with a schema you can select a content type</div></td></tr><tr><td><span class="psx-property-name ">schema</span></td><td><span class="psx-property-type"><a class="psx-type-link" data-name="PropertyType">PropertyType</a></span><br /><div class="psx-property-description"></div></td></tr></tbody></table></div> - - -<div id="TypeSchema" class="psx-object psx-struct"><h1><a class="psx-type-link" data-name="TypeSchema">TypeSchema</a></h1><div class="psx-object-description">TypeSchema specification</div><pre class="psx-object-json"><span class="psx-object-json-pun">{</span> - <span class="psx-object-json-key">"import"</span><span class="psx-object-json-pun">: </span><span class="psx-property-type">Map (String)</span><span class="psx-object-json-pun">,</span> - <span class="psx-object-json-key">"definitions"</span><span class="psx-object-json-pun">: </span><span class="psx-property-type">Map (DefinitionType)</span><span class="psx-object-json-pun">,</span> - <span class="psx-object-json-key">"root"</span><span class="psx-object-json-pun">: </span><span class="psx-property-type">String</span><span class="psx-object-json-pun">,</span> -<span class="psx-object-json-pun">}</span></pre><table class="table psx-object-properties"><colgroup><col width="30%" /><col width="70%" /></colgroup><thead><tr><th>Field</th><th>Description</th></tr></thead><tbody><tr><td><span class="psx-property-name ">import</span></td><td><span class="psx-property-type"><a class="psx-type-link" data-name="Map (String)">Map (String)</a></span><br /><div class="psx-property-description">Through the import keyword it is possible to import other TypeSchema documents. It contains a map where the key is the namespace and the value points to a remote document. The value is a URL and a code generator should support at least the following schemes: file, http, https.</div></td></tr><tr><td><span class="psx-property-name ">definitions</span></td><td><span class="psx-property-type"><a class="psx-type-link" data-name="Map (DefinitionType)">Map (DefinitionType)</a></span><br /><div class="psx-property-description"></div></td></tr><tr><td><span class="psx-property-name ">root</span></td><td><span class="psx-property-type"><a class="psx-type-link" data-name="String">String</a></span><br /><div class="psx-property-description">Specifies the root type of your specification.</div></td></tr></tbody></table></div> - - -<div id="TypeAPI" class="psx-object psx-struct"><h1><a class="psx-type-link" data-name="TypeAPI">TypeAPI</a> extends <a class="psx-type-link" data-name="TypeSchema">TypeSchema</a></h1><div class="psx-object-description">The TypeAPI Root</div><pre class="psx-object-json"><span class="psx-object-json-pun">{</span> - <span class="psx-object-json-key">"baseUrl"</span><span class="psx-object-json-pun">: </span><span class="psx-property-type">String</span><span class="psx-object-json-pun">,</span> - <span class="psx-object-json-key">"security"</span><span class="psx-object-json-pun">: </span><span class="psx-property-type">Security</span><span class="psx-object-json-pun">,</span> - <span class="psx-object-json-key">"operations"</span><span class="psx-object-json-pun">: </span><span class="psx-property-type">Map (Operation)</span><span class="psx-object-json-pun">,</span> -<span class="psx-object-json-pun">}</span></pre><table class="table psx-object-properties"><colgroup><col width="30%" /><col width="70%" /></colgroup><thead><tr><th>Field</th><th>Description</th></tr></thead><tbody><tr><td><span class="psx-property-name ">baseUrl</span></td><td><span class="psx-property-type"><a class="psx-type-link" data-name="String">String</a></span><br /><div class="psx-property-description">Optional the base url of the service, if provided the user does not need to provide a base url for your client</div></td></tr><tr><td><span class="psx-property-name ">security</span></td><td><span class="psx-property-type"><a class="psx-type-link" data-name="Security">Security</a></span><br /><div class="psx-property-description">Describes the authorization mechanism which is used by your API</div></td></tr><tr><td><span class="psx-property-name ">operations</span></td><td><span class="psx-property-type"><a class="psx-type-link" data-name="Map (Operation)">Map (Operation)</a></span><br /><div class="psx-property-description">A map of operations which are provided by the API. The key of the operation should be separated by a dot to group operations into logical units i.e. product.getAll or enterprise.product.execute</div></td></tr></tbody></table></div> - - <div id="DefinitionType" class="psx-object psx-struct"><h1><a class="psx-type-link" data-name="DefinitionType">DefinitionType</a></h1><div class="psx-object-description">Base definition type</div><pre class="psx-object-json"><span class="psx-object-json-pun">{</span> + <span class="psx-object-json-key">"deprecated"</span><span class="psx-object-json-pun">: </span><span class="psx-property-type">Boolean</span><span class="psx-object-json-pun">,</span> <span class="psx-object-json-key">"description"</span><span class="psx-object-json-pun">: </span><span class="psx-property-type">String</span><span class="psx-object-json-pun">,</span> <span class="psx-object-json-key">"type"</span><span class="psx-object-json-pun">: </span><span class="psx-property-type">String</span><span class="psx-object-json-pun">,</span> - <span class="psx-object-json-key">"deprecated"</span><span class="psx-object-json-pun">: </span><span class="psx-property-type">Boolean</span><span class="psx-object-json-pun">,</span> -<span class="psx-object-json-pun">}</span></pre><table class="table psx-object-properties"><colgroup><col width="30%" /><col width="70%" /></colgroup><thead><tr><th>Field</th><th>Description</th></tr></thead><tbody><tr><td><span class="psx-property-name ">description</span></td><td><span class="psx-property-type"><a class="psx-type-link" data-name="String">String</a></span><br /><div class="psx-property-description"></div></td></tr><tr><td><span class="psx-property-name ">type</span></td><td><span class="psx-property-type"><a class="psx-type-link" data-name="String">String</a></span><br /><div class="psx-property-description"></div></td></tr><tr><td><span class="psx-property-name ">deprecated</span></td><td><span class="psx-property-type"><a class="psx-type-link" data-name="Boolean">Boolean</a></span><br /><div class="psx-property-description"></div></td></tr></tbody></table></div> - - -<div id="StructDefinitionType" class="psx-object psx-struct"><h1><a class="psx-type-link" data-name="StructDefinitionType">StructDefinitionType</a> extends <a class="psx-type-link" data-name="DefinitionType">DefinitionType</a></h1><div class="psx-object-description">A struct represents a class/structure with a fix set of defined properties.</div><pre class="psx-object-json"><span class="psx-object-json-pun">{</span> - <span class="psx-object-json-key">"parent"</span><span class="psx-object-json-pun">: </span><span class="psx-property-type">ReferencePropertyType</span><span class="psx-object-json-pun">,</span> - <span class="psx-object-json-key">"base"</span><span class="psx-object-json-pun">: </span><span class="psx-property-type">Boolean</span><span class="psx-object-json-pun">,</span> - <span class="psx-object-json-key">"properties"</span><span class="psx-object-json-pun">: </span><span class="psx-property-type">Map (PropertyType)</span><span class="psx-object-json-pun">,</span> - <span class="psx-object-json-key">"discriminator"</span><span class="psx-object-json-pun">: </span><span class="psx-property-type">String</span><span class="psx-object-json-pun">,</span> - <span class="psx-object-json-key">"mapping"</span><span class="psx-object-json-pun">: </span><span class="psx-property-type">Map (String)</span><span class="psx-object-json-pun">,</span> -<span class="psx-object-json-pun">}</span></pre><table class="table psx-object-properties"><colgroup><col width="30%" /><col width="70%" /></colgroup><thead><tr><th>Field</th><th>Description</th></tr></thead><tbody><tr><td><span class="psx-property-name ">parent</span></td><td><span class="psx-property-type"><a class="psx-type-link" data-name="ReferencePropertyType">ReferencePropertyType</a></span><br /><div class="psx-property-description">Defines a parent type for this structure. Some programming languages like Go do not support the concept of an extends, in this case the code generator simply copies all properties into this structure.</div></td></tr><tr><td><span class="psx-property-name ">base</span></td><td><span class="psx-property-type"><a class="psx-type-link" data-name="Boolean">Boolean</a></span><br /><div class="psx-property-description">Indicates whether this is a base structure, default is false. If true the structure is used a base type, this means it is not possible to create an instance from this structure.</div></td></tr><tr><td><span class="psx-property-name ">properties</span></td><td><span class="psx-property-type"><a class="psx-type-link" data-name="Map (PropertyType)">Map (PropertyType)</a></span><br /><div class="psx-property-description">Contains a map of available properties for this struct.</div></td></tr><tr><td><span class="psx-property-name ">discriminator</span></td><td><span class="psx-property-type"><a class="psx-type-link" data-name="String">String</a></span><br /><div class="psx-property-description">Optional the property name of a discriminator property. This should be only used in case this is also a base structure.</div></td></tr><tr><td><span class="psx-property-name ">mapping</span></td><td><span class="psx-property-type"><a class="psx-type-link" data-name="Map (String)">Map (String)</a></span><br /><div class="psx-property-description">In case a discriminator is configured it is required to configure a mapping. The mapping is a map where the key is the type name and the value the actual discriminator type value.</div></td></tr></tbody></table></div> +<span class="psx-object-json-pun">}</span></pre><table class="table psx-object-properties"><colgroup><col width="30%" /><col width="70%" /></colgroup><thead><tr><th>Field</th><th>Description</th></tr></thead><tbody><tr><td><span class="psx-property-name ">deprecated</span></td><td><span class="psx-property-type"><a class="psx-type-link" data-name="Boolean">Boolean</a></span><br /><div class="psx-property-description"></div></td></tr><tr><td><span class="psx-property-name ">description</span></td><td><span class="psx-property-type"><a class="psx-type-link" data-name="String">String</a></span><br /><div class="psx-property-description"></div></td></tr><tr><td><span class="psx-property-name ">type</span></td><td><span class="psx-property-type"><a class="psx-type-link" data-name="String">String</a></span><br /><div class="psx-property-description"></div></td></tr></tbody></table></div> <div id="CollectionDefinitionType" class="psx-object psx-struct"><h1><a class="psx-type-link" data-name="CollectionDefinitionType">CollectionDefinitionType</a> extends <a class="psx-type-link" data-name="DefinitionType">DefinitionType</a></h1><div class="psx-object-description">Base collection type</div><pre class="psx-object-json"><span class="psx-object-json-pun">{</span> <span class="psx-object-json-key">"schema"</span><span class="psx-object-json-pun">: </span><span class="psx-property-type">PropertyType</span><span class="psx-object-json-pun">,</span> -<span class="psx-object-json-pun">}</span></pre><table class="table psx-object-properties"><colgroup><col width="30%" /><col width="70%" /></colgroup><thead><tr><th>Field</th><th>Description</th></tr></thead><tbody><tr><td><span class="psx-property-name ">schema</span></td><td><span class="psx-property-type"><a class="psx-type-link" data-name="PropertyType">PropertyType</a></span><br /><div class="psx-property-description"></div></td></tr></tbody></table></div> - - -<div id="MapDefinitionType" class="psx-object psx-struct"><h1><a class="psx-type-link" data-name="MapDefinitionType">MapDefinitionType</a> extends <a class="psx-type-link" data-name="CollectionDefinitionType">CollectionDefinitionType</a></h1><div class="psx-object-description">Represents a map which contains a dynamic set of key value entries of the same type</div><pre class="psx-object-json"><span class="psx-object-json-pun">{</span> -<span class="psx-object-json-pun">}</span></pre><table class="table psx-object-properties"><colgroup><col width="30%" /><col width="70%" /></colgroup><thead><tr><th>Field</th><th>Description</th></tr></thead><tbody></tbody></table></div> + <span class="psx-object-json-key">"type"</span><span class="psx-object-json-pun">: </span><span class="psx-property-type">String</span><span class="psx-object-json-pun">,</span> +<span class="psx-object-json-pun">}</span></pre><table class="table psx-object-properties"><colgroup><col width="30%" /><col width="70%" /></colgroup><thead><tr><th>Field</th><th>Description</th></tr></thead><tbody><tr><td><span class="psx-property-name ">schema</span></td><td><span class="psx-property-type"><a class="psx-type-link" data-name="PropertyType">PropertyType</a></span><br /><div class="psx-property-description"></div></td></tr><tr><td><span class="psx-property-name ">type</span></td><td><span class="psx-property-type"><a class="psx-type-link" data-name="String">String</a></span><br /><div class="psx-property-description"></div></td></tr></tbody></table></div> <div id="ArrayDefinitionType" class="psx-object psx-struct"><h1><a class="psx-type-link" data-name="ArrayDefinitionType">ArrayDefinitionType</a> extends <a class="psx-type-link" data-name="CollectionDefinitionType">CollectionDefinitionType</a></h1><div class="psx-object-description">Represents an array which contains a dynamic list of values of the same type</div><pre class="psx-object-json"><span class="psx-object-json-pun">{</span> <span class="psx-object-json-pun">}</span></pre><table class="table psx-object-properties"><colgroup><col width="30%" /><col width="70%" /></colgroup><thead><tr><th>Field</th><th>Description</th></tr></thead><tbody></tbody></table></div> -<div id="PropertyType" class="psx-object psx-struct"><h1><a class="psx-type-link" data-name="PropertyType">PropertyType</a></h1><div class="psx-object-description">Base property type</div><pre class="psx-object-json"><span class="psx-object-json-pun">{</span> - <span class="psx-object-json-key">"description"</span><span class="psx-object-json-pun">: </span><span class="psx-property-type">String</span><span class="psx-object-json-pun">,</span> +<div id="CollectionPropertyType" class="psx-object psx-struct"><h1><a class="psx-type-link" data-name="CollectionPropertyType">CollectionPropertyType</a> extends <a class="psx-type-link" data-name="PropertyType">PropertyType</a></h1><div class="psx-object-description">Base collection property type</div><pre class="psx-object-json"><span class="psx-object-json-pun">{</span> + <span class="psx-object-json-key">"schema"</span><span class="psx-object-json-pun">: </span><span class="psx-property-type">PropertyType</span><span class="psx-object-json-pun">,</span> <span class="psx-object-json-key">"type"</span><span class="psx-object-json-pun">: </span><span class="psx-property-type">String</span><span class="psx-object-json-pun">,</span> - <span class="psx-object-json-key">"deprecated"</span><span class="psx-object-json-pun">: </span><span class="psx-property-type">Boolean</span><span class="psx-object-json-pun">,</span> - <span class="psx-object-json-key">"nullable"</span><span class="psx-object-json-pun">: </span><span class="psx-property-type">Boolean</span><span class="psx-object-json-pun">,</span> -<span class="psx-object-json-pun">}</span></pre><table class="table psx-object-properties"><colgroup><col width="30%" /><col width="70%" /></colgroup><thead><tr><th>Field</th><th>Description</th></tr></thead><tbody><tr><td><span class="psx-property-name ">description</span></td><td><span class="psx-property-type"><a class="psx-type-link" data-name="String">String</a></span><br /><div class="psx-property-description"></div></td></tr><tr><td><span class="psx-property-name ">type</span></td><td><span class="psx-property-type"><a class="psx-type-link" data-name="String">String</a></span><br /><div class="psx-property-description"></div></td></tr><tr><td><span class="psx-property-name ">deprecated</span></td><td><span class="psx-property-type"><a class="psx-type-link" data-name="Boolean">Boolean</a></span><br /><div class="psx-property-description"></div></td></tr><tr><td><span class="psx-property-name ">nullable</span></td><td><span class="psx-property-type"><a class="psx-type-link" data-name="Boolean">Boolean</a></span><br /><div class="psx-property-description"></div></td></tr></tbody></table></div> - +<span class="psx-object-json-pun">}</span></pre><table class="table psx-object-properties"><colgroup><col width="30%" /><col width="70%" /></colgroup><thead><tr><th>Field</th><th>Description</th></tr></thead><tbody><tr><td><span class="psx-property-name ">schema</span></td><td><span class="psx-property-type"><a class="psx-type-link" data-name="PropertyType">PropertyType</a></span><br /><div class="psx-property-description"></div></td></tr><tr><td><span class="psx-property-name ">type</span></td><td><span class="psx-property-type"><a class="psx-type-link" data-name="String">String</a></span><br /><div class="psx-property-description"></div></td></tr></tbody></table></div> -<div id="ScalarPropertyType" class="psx-object psx-struct"><h1><a class="psx-type-link" data-name="ScalarPropertyType">ScalarPropertyType</a> extends <a class="psx-type-link" data-name="PropertyType">PropertyType</a></h1><div class="psx-object-description">Base scalar property type</div><pre class="psx-object-json"><span class="psx-object-json-pun">{</span> -<span class="psx-object-json-pun">}</span></pre><table class="table psx-object-properties"><colgroup><col width="30%" /><col width="70%" /></colgroup><thead><tr><th>Field</th><th>Description</th></tr></thead><tbody></tbody></table></div> - -<div id="StringPropertyType" class="psx-object psx-struct"><h1><a class="psx-type-link" data-name="StringPropertyType">StringPropertyType</a> extends <a class="psx-type-link" data-name="ScalarPropertyType">ScalarPropertyType</a></h1><div class="psx-object-description">Represents a string value</div><pre class="psx-object-json"><span class="psx-object-json-pun">{</span> - <span class="psx-object-json-key">"format"</span><span class="psx-object-json-pun">: </span><span class="psx-property-type">String</span><span class="psx-object-json-pun">,</span> -<span class="psx-object-json-pun">}</span></pre><table class="table psx-object-properties"><colgroup><col width="30%" /><col width="70%" /></colgroup><thead><tr><th>Field</th><th>Description</th></tr></thead><tbody><tr><td><span class="psx-property-name ">format</span></td><td><span class="psx-property-type"><a class="psx-type-link" data-name="String">String</a></span><br /><div class="psx-property-description">Optional describes the format of the string. Supported are the following types: date, date-time and time. A code generator may use a fitting data type to represent such a format, if not supported it should fall back to a string.</div></td></tr></tbody></table></div> - - -<div id="IntegerPropertyType" class="psx-object psx-struct"><h1><a class="psx-type-link" data-name="IntegerPropertyType">IntegerPropertyType</a> extends <a class="psx-type-link" data-name="ScalarPropertyType">ScalarPropertyType</a></h1><div class="psx-object-description">Represents an integer value</div><pre class="psx-object-json"><span class="psx-object-json-pun">{</span> +<div id="ArrayPropertyType" class="psx-object psx-struct"><h1><a class="psx-type-link" data-name="ArrayPropertyType">ArrayPropertyType</a> extends <a class="psx-type-link" data-name="CollectionPropertyType">CollectionPropertyType</a></h1><div class="psx-object-description">Represents an array which contains a dynamic list of values of the same type</div><pre class="psx-object-json"><span class="psx-object-json-pun">{</span> <span class="psx-object-json-pun">}</span></pre><table class="table psx-object-properties"><colgroup><col width="30%" /><col width="70%" /></colgroup><thead><tr><th>Field</th><th>Description</th></tr></thead><tbody></tbody></table></div> -<div id="NumberPropertyType" class="psx-object psx-struct"><h1><a class="psx-type-link" data-name="NumberPropertyType">NumberPropertyType</a> extends <a class="psx-type-link" data-name="ScalarPropertyType">ScalarPropertyType</a></h1><div class="psx-object-description">Represents a float value</div><pre class="psx-object-json"><span class="psx-object-json-pun">{</span> -<span class="psx-object-json-pun">}</span></pre><table class="table psx-object-properties"><colgroup><col width="30%" /><col width="70%" /></colgroup><thead><tr><th>Field</th><th>Description</th></tr></thead><tbody></tbody></table></div> +<div id="ScalarPropertyType" class="psx-object psx-struct"><h1><a class="psx-type-link" data-name="ScalarPropertyType">ScalarPropertyType</a> extends <a class="psx-type-link" data-name="PropertyType">PropertyType</a></h1><div class="psx-object-description">Base scalar property type</div><pre class="psx-object-json"><span class="psx-object-json-pun">{</span> + <span class="psx-object-json-key">"type"</span><span class="psx-object-json-pun">: </span><span class="psx-property-type">String</span><span class="psx-object-json-pun">,</span> +<span class="psx-object-json-pun">}</span></pre><table class="table psx-object-properties"><colgroup><col width="30%" /><col width="70%" /></colgroup><thead><tr><th>Field</th><th>Description</th></tr></thead><tbody><tr><td><span class="psx-property-name ">type</span></td><td><span class="psx-property-type"><a class="psx-type-link" data-name="String">String</a></span><br /><div class="psx-property-description"></div></td></tr></tbody></table></div> <div id="BooleanPropertyType" class="psx-object psx-struct"><h1><a class="psx-type-link" data-name="BooleanPropertyType">BooleanPropertyType</a> extends <a class="psx-type-link" data-name="ScalarPropertyType">ScalarPropertyType</a></h1><div class="psx-object-description">Represents a boolean value</div><pre class="psx-object-json"><span class="psx-object-json-pun">{</span> <span class="psx-object-json-pun">}</span></pre><table class="table psx-object-properties"><colgroup><col width="30%" /><col width="70%" /></colgroup><thead><tr><th>Field</th><th>Description</th></tr></thead><tbody></tbody></table></div> -<div id="CollectionPropertyType" class="psx-object psx-struct"><h1><a class="psx-type-link" data-name="CollectionPropertyType">CollectionPropertyType</a> extends <a class="psx-type-link" data-name="PropertyType">PropertyType</a></h1><div class="psx-object-description">Base collection property type</div><pre class="psx-object-json"><span class="psx-object-json-pun">{</span> - <span class="psx-object-json-key">"schema"</span><span class="psx-object-json-pun">: </span><span class="psx-property-type">PropertyType</span><span class="psx-object-json-pun">,</span> -<span class="psx-object-json-pun">}</span></pre><table class="table psx-object-properties"><colgroup><col width="30%" /><col width="70%" /></colgroup><thead><tr><th>Field</th><th>Description</th></tr></thead><tbody><tr><td><span class="psx-property-name ">schema</span></td><td><span class="psx-property-type"><a class="psx-type-link" data-name="PropertyType">PropertyType</a></span><br /><div class="psx-property-description"></div></td></tr></tbody></table></div> +<div id="GenericPropertyType" class="psx-object psx-struct"><h1><a class="psx-type-link" data-name="GenericPropertyType">GenericPropertyType</a> extends <a class="psx-type-link" data-name="PropertyType">PropertyType</a></h1><div class="psx-object-description">Represents a generic value which can be replaced with a dynamic type</div><pre class="psx-object-json"><span class="psx-object-json-pun">{</span> + <span class="psx-object-json-key">"name"</span><span class="psx-object-json-pun">: </span><span class="psx-property-type">String</span><span class="psx-object-json-pun">,</span> +<span class="psx-object-json-pun">}</span></pre><table class="table psx-object-properties"><colgroup><col width="30%" /><col width="70%" /></colgroup><thead><tr><th>Field</th><th>Description</th></tr></thead><tbody><tr><td><span class="psx-property-name ">name</span></td><td><span class="psx-property-type"><a class="psx-type-link" data-name="String">String</a></span><br /><div class="psx-property-description">The name of the generic, it is recommended to use common generic names like T or TValue. These generics can then be replaced on usage with a concrete type through the template property at a reference.</div></td></tr></tbody></table></div> -<div id="MapPropertyType" class="psx-object psx-struct"><h1><a class="psx-type-link" data-name="MapPropertyType">MapPropertyType</a> extends <a class="psx-type-link" data-name="CollectionPropertyType">CollectionPropertyType</a></h1><div class="psx-object-description">Represents a map which contains a dynamic set of key value entries of the same type</div><pre class="psx-object-json"><span class="psx-object-json-pun">{</span> +<div id="IntegerPropertyType" class="psx-object psx-struct"><h1><a class="psx-type-link" data-name="IntegerPropertyType">IntegerPropertyType</a> extends <a class="psx-type-link" data-name="ScalarPropertyType">ScalarPropertyType</a></h1><div class="psx-object-description">Represents an integer value</div><pre class="psx-object-json"><span class="psx-object-json-pun">{</span> <span class="psx-object-json-pun">}</span></pre><table class="table psx-object-properties"><colgroup><col width="30%" /><col width="70%" /></colgroup><thead><tr><th>Field</th><th>Description</th></tr></thead><tbody></tbody></table></div> -<div id="ArrayPropertyType" class="psx-object psx-struct"><h1><a class="psx-type-link" data-name="ArrayPropertyType">ArrayPropertyType</a> extends <a class="psx-type-link" data-name="CollectionPropertyType">CollectionPropertyType</a></h1><div class="psx-object-description">Represents an array which contains a dynamic list of values of the same type</div><pre class="psx-object-json"><span class="psx-object-json-pun">{</span> +<div id="MapDefinitionType" class="psx-object psx-struct"><h1><a class="psx-type-link" data-name="MapDefinitionType">MapDefinitionType</a> extends <a class="psx-type-link" data-name="CollectionDefinitionType">CollectionDefinitionType</a></h1><div class="psx-object-description">Represents a map which contains a dynamic set of key value entries of the same type</div><pre class="psx-object-json"><span class="psx-object-json-pun">{</span> <span class="psx-object-json-pun">}</span></pre><table class="table psx-object-properties"><colgroup><col width="30%" /><col width="70%" /></colgroup><thead><tr><th>Field</th><th>Description</th></tr></thead><tbody></tbody></table></div> -<div id="AnyPropertyType" class="psx-object psx-struct"><h1><a class="psx-type-link" data-name="AnyPropertyType">AnyPropertyType</a> extends <a class="psx-type-link" data-name="PropertyType">PropertyType</a></h1><div class="psx-object-description">Represents an any value which allows any kind of value</div><pre class="psx-object-json"><span class="psx-object-json-pun">{</span> +<div id="MapPropertyType" class="psx-object psx-struct"><h1><a class="psx-type-link" data-name="MapPropertyType">MapPropertyType</a> extends <a class="psx-type-link" data-name="CollectionPropertyType">CollectionPropertyType</a></h1><div class="psx-object-description">Represents a map which contains a dynamic set of key value entries of the same type</div><pre class="psx-object-json"><span class="psx-object-json-pun">{</span> <span class="psx-object-json-pun">}</span></pre><table class="table psx-object-properties"><colgroup><col width="30%" /><col width="70%" /></colgroup><thead><tr><th>Field</th><th>Description</th></tr></thead><tbody></tbody></table></div> -<div id="GenericPropertyType" class="psx-object psx-struct"><h1><a class="psx-type-link" data-name="GenericPropertyType">GenericPropertyType</a> extends <a class="psx-type-link" data-name="PropertyType">PropertyType</a></h1><div class="psx-object-description">Represents a generic value which can be replaced with a dynamic type</div><pre class="psx-object-json"><span class="psx-object-json-pun">{</span> - <span class="psx-object-json-key">"name"</span><span class="psx-object-json-pun">: </span><span class="psx-property-type">String</span><span class="psx-object-json-pun">,</span> -<span class="psx-object-json-pun">}</span></pre><table class="table psx-object-properties"><colgroup><col width="30%" /><col width="70%" /></colgroup><thead><tr><th>Field</th><th>Description</th></tr></thead><tbody><tr><td><span class="psx-property-name ">name</span></td><td><span class="psx-property-type"><a class="psx-type-link" data-name="String">String</a></span><br /><div class="psx-property-description">The name of the generic, it is recommended to use common generic names like T or TValue. These generics can then be replaced on usage with a concrete type through the template property at a reference.</div></td></tr></tbody></table></div> +<div id="NumberPropertyType" class="psx-object psx-struct"><h1><a class="psx-type-link" data-name="NumberPropertyType">NumberPropertyType</a> extends <a class="psx-type-link" data-name="ScalarPropertyType">ScalarPropertyType</a></h1><div class="psx-object-description">Represents a float value</div><pre class="psx-object-json"><span class="psx-object-json-pun">{</span> +<span class="psx-object-json-pun">}</span></pre><table class="table psx-object-properties"><colgroup><col width="30%" /><col width="70%" /></colgroup><thead><tr><th>Field</th><th>Description</th></tr></thead><tbody></tbody></table></div> <div id="ReferencePropertyType" class="psx-object psx-struct"><h1><a class="psx-type-link" data-name="ReferencePropertyType">ReferencePropertyType</a> extends <a class="psx-type-link" data-name="PropertyType">PropertyType</a></h1><div class="psx-object-description">Represents a reference to a definition type</div><pre class="psx-object-json"><span class="psx-object-json-pun">{</span> @@ -152,3 +72,24 @@ <span class="psx-object-json-key">"template"</span><span class="psx-object-json-pun">: </span><span class="psx-property-type">Map (String)</span><span class="psx-object-json-pun">,</span> <span class="psx-object-json-pun">}</span></pre><table class="table psx-object-properties"><colgroup><col width="30%" /><col width="70%" /></colgroup><thead><tr><th>Field</th><th>Description</th></tr></thead><tbody><tr><td><span class="psx-property-name ">target</span></td><td><span class="psx-property-type"><a class="psx-type-link" data-name="String">String</a></span><br /><div class="psx-property-description">The target type, this must be a key which is available under the definitions keyword.</div></td></tr><tr><td><span class="psx-property-name ">template</span></td><td><span class="psx-property-type"><a class="psx-type-link" data-name="Map (String)">Map (String)</a></span><br /><div class="psx-property-description">A map where the key is the name of the generic and the value must point to a key under the definitions keyword. This can be used in case the target points to a type which contains generics, then it is possible to replace those generics with a concrete type.</div></td></tr></tbody></table></div> + +<div id="StringPropertyType" class="psx-object psx-struct"><h1><a class="psx-type-link" data-name="StringPropertyType">StringPropertyType</a> extends <a class="psx-type-link" data-name="ScalarPropertyType">ScalarPropertyType</a></h1><div class="psx-object-description">Represents a string value</div><pre class="psx-object-json"><span class="psx-object-json-pun">{</span> + <span class="psx-object-json-key">"format"</span><span class="psx-object-json-pun">: </span><span class="psx-property-type">String</span><span class="psx-object-json-pun">,</span> +<span class="psx-object-json-pun">}</span></pre><table class="table psx-object-properties"><colgroup><col width="30%" /><col width="70%" /></colgroup><thead><tr><th>Field</th><th>Description</th></tr></thead><tbody><tr><td><span class="psx-property-name ">format</span></td><td><span class="psx-property-type"><a class="psx-type-link" data-name="String">String</a></span><br /><div class="psx-property-description">Optional describes the format of the string. Supported are the following types: date, date-time and time. A code generator may use a fitting data type to represent such a format, if not supported it should fall back to a string.</div></td></tr></tbody></table></div> + + +<div id="StructDefinitionType" class="psx-object psx-struct"><h1><a class="psx-type-link" data-name="StructDefinitionType">StructDefinitionType</a> extends <a class="psx-type-link" data-name="DefinitionType">DefinitionType</a></h1><div class="psx-object-description">A struct represents a class/structure with a fix set of defined properties.</div><pre class="psx-object-json"><span class="psx-object-json-pun">{</span> + <span class="psx-object-json-key">"base"</span><span class="psx-object-json-pun">: </span><span class="psx-property-type">Boolean</span><span class="psx-object-json-pun">,</span> + <span class="psx-object-json-key">"discriminator"</span><span class="psx-object-json-pun">: </span><span class="psx-property-type">String</span><span class="psx-object-json-pun">,</span> + <span class="psx-object-json-key">"mapping"</span><span class="psx-object-json-pun">: </span><span class="psx-property-type">Map (String)</span><span class="psx-object-json-pun">,</span> + <span class="psx-object-json-key">"parent"</span><span class="psx-object-json-pun">: </span><span class="psx-property-type">ReferencePropertyType</span><span class="psx-object-json-pun">,</span> + <span class="psx-object-json-key">"properties"</span><span class="psx-object-json-pun">: </span><span class="psx-property-type">Map (PropertyType)</span><span class="psx-object-json-pun">,</span> +<span class="psx-object-json-pun">}</span></pre><table class="table psx-object-properties"><colgroup><col width="30%" /><col width="70%" /></colgroup><thead><tr><th>Field</th><th>Description</th></tr></thead><tbody><tr><td><span class="psx-property-name ">base</span></td><td><span class="psx-property-type"><a class="psx-type-link" data-name="Boolean">Boolean</a></span><br /><div class="psx-property-description">Indicates whether this is a base structure, default is false. If true the structure is used a base type, this means it is not possible to create an instance from this structure.</div></td></tr><tr><td><span class="psx-property-name ">discriminator</span></td><td><span class="psx-property-type"><a class="psx-type-link" data-name="String">String</a></span><br /><div class="psx-property-description">Optional the property name of a discriminator property. This should be only used in case this is also a base structure.</div></td></tr><tr><td><span class="psx-property-name ">mapping</span></td><td><span class="psx-property-type"><a class="psx-type-link" data-name="Map (String)">Map (String)</a></span><br /><div class="psx-property-description">In case a discriminator is configured it is required to configure a mapping. The mapping is a map where the key is the type name and the value the actual discriminator type value.</div></td></tr><tr><td><span class="psx-property-name ">parent</span></td><td><span class="psx-property-type"><a class="psx-type-link" data-name="ReferencePropertyType">ReferencePropertyType</a></span><br /><div class="psx-property-description">Defines a parent type for this structure. Some programming languages like Go do not support the concept of an extends, in this case the code generator simply copies all properties into this structure.</div></td></tr><tr><td><span class="psx-property-name ">properties</span></td><td><span class="psx-property-type"><a class="psx-type-link" data-name="Map (PropertyType)">Map (PropertyType)</a></span><br /><div class="psx-property-description">Contains a map of available properties for this struct.</div></td></tr></tbody></table></div> + + +<div id="TypeSchema" class="psx-object psx-struct"><h1><a class="psx-type-link" data-name="TypeSchema">TypeSchema</a></h1><div class="psx-object-description">TypeSchema specification</div><pre class="psx-object-json"><span class="psx-object-json-pun">{</span> + <span class="psx-object-json-key">"definitions"</span><span class="psx-object-json-pun">: </span><span class="psx-property-type">Map (DefinitionType)</span><span class="psx-object-json-pun">,</span> + <span class="psx-object-json-key">"import"</span><span class="psx-object-json-pun">: </span><span class="psx-property-type">Map (String)</span><span class="psx-object-json-pun">,</span> + <span class="psx-object-json-key">"root"</span><span class="psx-object-json-pun">: </span><span class="psx-property-type">String</span><span class="psx-object-json-pun">,</span> +<span class="psx-object-json-pun">}</span></pre><table class="table psx-object-properties"><colgroup><col width="30%" /><col width="70%" /></colgroup><thead><tr><th>Field</th><th>Description</th></tr></thead><tbody><tr><td><span class="psx-property-name ">definitions</span></td><td><span class="psx-property-type"><a class="psx-type-link" data-name="Map (DefinitionType)">Map (DefinitionType)</a></span><br /><div class="psx-property-description"></div></td></tr><tr><td><span class="psx-property-name ">import</span></td><td><span class="psx-property-type"><a class="psx-type-link" data-name="Map (String)">Map (String)</a></span><br /><div class="psx-property-description">Through the import keyword it is possible to import other TypeSchema documents. It contains a map where the key is the namespace and the value points to a remote document. The value is a URL and a code generator should support at least the following schemes: file, http, https.</div></td></tr><tr><td><span class="psx-property-name ">root</span></td><td><span class="psx-property-type"><a class="psx-type-link" data-name="String">String</a></span><br /><div class="psx-property-description">Specifies the root type of your specification.</div></td></tr></tbody></table></div> + diff --git a/tests/Generator/resource/java/complex/CollectionDefinitionType.java b/tests/Generator/resource/java/complex/CollectionDefinitionType.java index f59b1b6..6c0f651 100644 --- a/tests/Generator/resource/java/complex/CollectionDefinitionType.java +++ b/tests/Generator/resource/java/complex/CollectionDefinitionType.java @@ -7,11 +7,12 @@ */ @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type") @JsonSubTypes({ - @JsonSubTypes.Type(value = MapDefinitionType.class, name = "map"), @JsonSubTypes.Type(value = ArrayDefinitionType.class, name = "array"), + @JsonSubTypes.Type(value = MapDefinitionType.class, name = "map"), }) public abstract class CollectionDefinitionType extends DefinitionType { private PropertyType schema; + private String type; @JsonSetter("schema") public void setSchema(PropertyType schema) { @@ -22,5 +23,15 @@ public void setSchema(PropertyType schema) { public PropertyType getSchema() { return this.schema; } + + @JsonSetter("type") + public void setType(String type) { + this.type = type; + } + + @JsonGetter("type") + public String getType() { + return this.type; + } } diff --git a/tests/Generator/resource/java/complex/CollectionPropertyType.java b/tests/Generator/resource/java/complex/CollectionPropertyType.java index 1b6a625..9557563 100644 --- a/tests/Generator/resource/java/complex/CollectionPropertyType.java +++ b/tests/Generator/resource/java/complex/CollectionPropertyType.java @@ -5,8 +5,14 @@ /** * Base collection property type */ +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type") +@JsonSubTypes({ + @JsonSubTypes.Type(value = ArrayPropertyType.class, name = "array"), + @JsonSubTypes.Type(value = MapPropertyType.class, name = "map"), +}) public abstract class CollectionPropertyType extends PropertyType { private PropertyType schema; + private String type; @JsonSetter("schema") public void setSchema(PropertyType schema) { @@ -17,5 +23,15 @@ public void setSchema(PropertyType schema) { public PropertyType getSchema() { return this.schema; } + + @JsonSetter("type") + public void setType(String type) { + this.type = type; + } + + @JsonGetter("type") + public String getType() { + return this.type; + } } diff --git a/tests/Generator/resource/java/complex/DefinitionType.java b/tests/Generator/resource/java/complex/DefinitionType.java index 0f6fe32..b9a2767 100644 --- a/tests/Generator/resource/java/complex/DefinitionType.java +++ b/tests/Generator/resource/java/complex/DefinitionType.java @@ -7,14 +7,24 @@ */ @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type") @JsonSubTypes({ - @JsonSubTypes.Type(value = StructDefinitionType.class, name = "struct"), - @JsonSubTypes.Type(value = MapDefinitionType.class, name = "map"), @JsonSubTypes.Type(value = ArrayDefinitionType.class, name = "array"), + @JsonSubTypes.Type(value = MapDefinitionType.class, name = "map"), + @JsonSubTypes.Type(value = StructDefinitionType.class, name = "struct"), }) public abstract class DefinitionType { + private Boolean deprecated; private String description; private String type; - private Boolean deprecated; + + @JsonSetter("deprecated") + public void setDeprecated(Boolean deprecated) { + this.deprecated = deprecated; + } + + @JsonGetter("deprecated") + public Boolean getDeprecated() { + return this.deprecated; + } @JsonSetter("description") public void setDescription(String description) { @@ -35,15 +45,5 @@ public void setType(String type) { public String getType() { return this.type; } - - @JsonSetter("deprecated") - public void setDeprecated(Boolean deprecated) { - this.deprecated = deprecated; - } - - @JsonGetter("deprecated") - public Boolean getDeprecated() { - return this.deprecated; - } } diff --git a/tests/Generator/resource/java/complex/PropertyType.java b/tests/Generator/resource/java/complex/PropertyType.java index b4e7582..4605c39 100644 --- a/tests/Generator/resource/java/complex/PropertyType.java +++ b/tests/Generator/resource/java/complex/PropertyType.java @@ -7,41 +7,21 @@ */ @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type") @JsonSubTypes({ - @JsonSubTypes.Type(value = StringPropertyType.class, name = "string"), - @JsonSubTypes.Type(value = IntegerPropertyType.class, name = "integer"), - @JsonSubTypes.Type(value = NumberPropertyType.class, name = "number"), - @JsonSubTypes.Type(value = BooleanPropertyType.class, name = "boolean"), - @JsonSubTypes.Type(value = MapPropertyType.class, name = "map"), - @JsonSubTypes.Type(value = ArrayPropertyType.class, name = "array"), @JsonSubTypes.Type(value = AnyPropertyType.class, name = "any"), + @JsonSubTypes.Type(value = ArrayPropertyType.class, name = "array"), + @JsonSubTypes.Type(value = BooleanPropertyType.class, name = "boolean"), @JsonSubTypes.Type(value = GenericPropertyType.class, name = "generic"), + @JsonSubTypes.Type(value = IntegerPropertyType.class, name = "integer"), + @JsonSubTypes.Type(value = MapPropertyType.class, name = "map"), + @JsonSubTypes.Type(value = NumberPropertyType.class, name = "number"), @JsonSubTypes.Type(value = ReferencePropertyType.class, name = "reference"), + @JsonSubTypes.Type(value = StringPropertyType.class, name = "string"), }) public abstract class PropertyType { - private String description; - private String type; private Boolean deprecated; + private String description; private Boolean nullable; - - @JsonSetter("description") - public void setDescription(String description) { - this.description = description; - } - - @JsonGetter("description") - public String getDescription() { - return this.description; - } - - @JsonSetter("type") - public void setType(String type) { - this.type = type; - } - - @JsonGetter("type") - public String getType() { - return this.type; - } + private String type; @JsonSetter("deprecated") public void setDeprecated(Boolean deprecated) { @@ -53,6 +33,16 @@ public Boolean getDeprecated() { return this.deprecated; } + @JsonSetter("description") + public void setDescription(String description) { + this.description = description; + } + + @JsonGetter("description") + public String getDescription() { + return this.description; + } + @JsonSetter("nullable") public void setNullable(Boolean nullable) { this.nullable = nullable; @@ -62,5 +52,15 @@ public void setNullable(Boolean nullable) { public Boolean getNullable() { return this.nullable; } + + @JsonSetter("type") + public void setType(String type) { + this.type = type; + } + + @JsonGetter("type") + public String getType() { + return this.type; + } } diff --git a/tests/Generator/resource/java/complex/ScalarPropertyType.java b/tests/Generator/resource/java/complex/ScalarPropertyType.java index 2d021fd..a110778 100644 --- a/tests/Generator/resource/java/complex/ScalarPropertyType.java +++ b/tests/Generator/resource/java/complex/ScalarPropertyType.java @@ -7,11 +7,22 @@ */ @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type") @JsonSubTypes({ - @JsonSubTypes.Type(value = StringPropertyType.class, name = "string"), + @JsonSubTypes.Type(value = BooleanPropertyType.class, name = "boolean"), @JsonSubTypes.Type(value = IntegerPropertyType.class, name = "integer"), @JsonSubTypes.Type(value = NumberPropertyType.class, name = "number"), - @JsonSubTypes.Type(value = BooleanPropertyType.class, name = "boolean"), + @JsonSubTypes.Type(value = StringPropertyType.class, name = "string"), }) public abstract class ScalarPropertyType extends PropertyType { + private String type; + + @JsonSetter("type") + public void setType(String type) { + this.type = type; + } + + @JsonGetter("type") + public String getType() { + return this.type; + } } diff --git a/tests/Generator/resource/java/complex/StructDefinitionType.java b/tests/Generator/resource/java/complex/StructDefinitionType.java index 0135723..a3cec94 100644 --- a/tests/Generator/resource/java/complex/StructDefinitionType.java +++ b/tests/Generator/resource/java/complex/StructDefinitionType.java @@ -6,21 +6,11 @@ * A struct represents a class/structure with a fix set of defined properties. */ public class StructDefinitionType extends DefinitionType { - private ReferencePropertyType parent; private Boolean base; - private java.util.Map<String, PropertyType> properties; private String discriminator; private java.util.Map<String, String> mapping; - - @JsonSetter("parent") - public void setParent(ReferencePropertyType parent) { - this.parent = parent; - } - - @JsonGetter("parent") - public ReferencePropertyType getParent() { - return this.parent; - } + private ReferencePropertyType parent; + private java.util.Map<String, PropertyType> properties; @JsonSetter("base") public void setBase(Boolean base) { @@ -32,16 +22,6 @@ public Boolean getBase() { return this.base; } - @JsonSetter("properties") - public void setProperties(java.util.Map<String, PropertyType> properties) { - this.properties = properties; - } - - @JsonGetter("properties") - public java.util.Map<String, PropertyType> getProperties() { - return this.properties; - } - @JsonSetter("discriminator") public void setDiscriminator(String discriminator) { this.discriminator = discriminator; @@ -61,5 +41,25 @@ public void setMapping(java.util.Map<String, String> mapping) { public java.util.Map<String, String> getMapping() { return this.mapping; } + + @JsonSetter("parent") + public void setParent(ReferencePropertyType parent) { + this.parent = parent; + } + + @JsonGetter("parent") + public ReferencePropertyType getParent() { + return this.parent; + } + + @JsonSetter("properties") + public void setProperties(java.util.Map<String, PropertyType> properties) { + this.properties = properties; + } + + @JsonGetter("properties") + public java.util.Map<String, PropertyType> getProperties() { + return this.properties; + } } diff --git a/tests/Generator/resource/java/complex/TypeSchema.java b/tests/Generator/resource/java/complex/TypeSchema.java index ee4d4e0..f434cce 100644 --- a/tests/Generator/resource/java/complex/TypeSchema.java +++ b/tests/Generator/resource/java/complex/TypeSchema.java @@ -6,20 +6,10 @@ * TypeSchema specification */ public class TypeSchema { - private java.util.Map<String, String> _import; private java.util.Map<String, DefinitionType> definitions; + private java.util.Map<String, String> _import; private String root; - @JsonSetter("import") - public void setImport(java.util.Map<String, String> _import) { - this._import = _import; - } - - @JsonGetter("import") - public java.util.Map<String, String> getImport() { - return this._import; - } - @JsonSetter("definitions") public void setDefinitions(java.util.Map<String, DefinitionType> definitions) { this.definitions = definitions; @@ -30,6 +20,16 @@ public java.util.Map<String, DefinitionType> getDefinitions() { return this.definitions; } + @JsonSetter("import") + public void setImport(java.util.Map<String, String> _import) { + this._import = _import; + } + + @JsonGetter("import") + public java.util.Map<String, String> getImport() { + return this._import; + } + @JsonSetter("root") public void setRoot(String root) { this.root = root; diff --git a/tests/Generator/resource/jsonschema/jsonschema_complex.json b/tests/Generator/resource/jsonschema/jsonschema_complex.json index 1b15d1b..b0d719c 100644 --- a/tests/Generator/resource/jsonschema/jsonschema_complex.json +++ b/tests/Generator/resource/jsonschema/jsonschema_complex.json @@ -11,27 +11,6 @@ } ] }, - "Argument": { - "description": "", - "type": "object", - "properties": { - "in": { - "description": "The location where the value can be found either in the path, query, header or body. If you choose path, then your path must have a fitting variable path fragment", - "type": "string" - }, - "schema": { - "$ref": "#/definitions/PropertyType" - }, - "contentType": { - "description": "In case the data is not a JSON payload which you can describe with a schema you can select a content type", - "type": "string" - }, - "name": { - "description": "Optional the actual path, query or header name. If not provided the key of the argument map is used", - "type": "string" - } - } - }, "ArrayDefinitionType": { "allOf": [ { @@ -77,12 +56,16 @@ "properties": { "schema": { "$ref": "#/definitions/PropertyType" + }, + "type": { + "description": "", + "type": "string" } }, "discriminator": "type", "mapping": { - "MapDefinitionType": "map", - "ArrayDefinitionType": "array" + "ArrayDefinitionType": "array", + "MapDefinitionType": "map" } } ] @@ -99,7 +82,16 @@ "properties": { "schema": { "$ref": "#/definitions/PropertyType" + }, + "type": { + "description": "", + "type": "string" } + }, + "discriminator": "type", + "mapping": { + "ArrayPropertyType": "array", + "MapPropertyType": "map" } } ] @@ -109,21 +101,24 @@ "type": "object", "base": true, "properties": { + "deprecated": { + "description": "", + "type": "boolean" + }, "description": { + "description": "", "type": "string" }, "type": { + "description": "", "type": "string" - }, - "deprecated": { - "type": "boolean" } }, "discriminator": "type", "mapping": { - "StructDefinitionType": "struct", + "ArrayDefinitionType": "array", "MapDefinitionType": "map", - "ArrayDefinitionType": "array" + "StructDefinitionType": "struct" } }, "GenericPropertyType": { @@ -187,92 +182,39 @@ } ] }, - "Operation": { - "description": "", - "type": "object", - "properties": { - "method": { - "description": "The HTTP method which is associated with this operation, must be a valid HTTP method i.e. GET, POST, PUT etc.", - "type": "string" - }, - "path": { - "description": "The HTTP path which is associated with this operation. A path can also include variable path fragments i.e. /my/path/:year then you can map the variable year path fragment to a specific argument", - "type": "string" - }, - "return": { - "$ref": "#/definitions/Response" - }, - "arguments": { - "description": "All arguments provided to this operation. Each argument is mapped to a location from the HTTP request i.e. query or body", - "type": "object", - "additionalProperties": { - "$ref": "#/definitions/Argument" - } - }, - "throws": { - "description": "All exceptional states which can occur in case the operation fails. Each exception is assigned to an HTTP error status code", - "type": "array", - "items": { - "$ref": "#/definitions/Response" - } - }, - "description": { - "description": "A short description of this operation. The generated code will include this description at the method so it is recommend to use simple alphanumeric characters and no new lines", - "type": "string" - }, - "stability": { - "description": "Indicates the stability of this operation: 0 - Deprecated, 1 - Experimental, 2 - Stable, 3 - Legacy. If not explicit provided the operation is by default experimental.", - "type": "integer" - }, - "security": { - "description": "An array of scopes which are required to access this operation", - "type": "array", - "items": { - "type": "string" - } - }, - "authorization": { - "description": "Indicates whether this operation needs authorization, if set to false the client will not send an authorization header, default it is true", - "type": "boolean" - }, - "tags": { - "description": "Optional an array of tags to group operations", - "type": "array", - "items": { - "type": "string" - } - } - } - }, "PropertyType": { "description": "Base property type", "type": "object", "base": true, "properties": { - "description": { - "type": "string" - }, - "type": { - "type": "string" - }, "deprecated": { + "description": "", "type": "boolean" }, + "description": { + "description": "", + "type": "string" + }, "nullable": { + "description": "", "type": "boolean" + }, + "type": { + "description": "", + "type": "string" } }, "discriminator": "type", "mapping": { - "StringPropertyType": "string", - "IntegerPropertyType": "integer", - "NumberPropertyType": "number", - "BooleanPropertyType": "boolean", - "MapPropertyType": "map", - "ArrayPropertyType": "array", "AnyPropertyType": "any", + "ArrayPropertyType": "array", + "BooleanPropertyType": "boolean", "GenericPropertyType": "generic", - "ReferencePropertyType": "reference" + "IntegerPropertyType": "integer", + "MapPropertyType": "map", + "NumberPropertyType": "number", + "ReferencePropertyType": "reference", + "StringPropertyType": "string" } }, "ReferencePropertyType": { @@ -299,23 +241,6 @@ } ] }, - "Response": { - "description": "", - "type": "object", - "properties": { - "code": { - "description": "The associated HTTP response code. For error responses it is possible to use the 499, 599 or 999 status code to catch all errors", - "type": "integer" - }, - "contentType": { - "description": "In case the data is not a JSON payload which you can describe with a schema you can select a content type", - "type": "string" - }, - "schema": { - "$ref": "#/definitions/PropertyType" - } - } - }, "ScalarPropertyType": { "allOf": [ { @@ -325,97 +250,18 @@ "description": "Base scalar property type", "type": "object", "base": true, + "properties": { + "type": { + "description": "", + "type": "string" + } + }, "discriminator": "type", "mapping": { - "StringPropertyType": "string", + "BooleanPropertyType": "boolean", "IntegerPropertyType": "integer", "NumberPropertyType": "number", - "BooleanPropertyType": "boolean" - } - } - ] - }, - "Security": { - "description": "", - "type": "object", - "base": true, - "properties": { - "type": { - "description": "The global security type of the API must be one of: httpBasic, httpBearer, apiKey or oauth2", - "type": "string" - } - }, - "discriminator": "type", - "mapping": { - "SecurityHttpBasic": "httpBasic", - "SecurityHttpBearer": "httpBearer", - "SecurityApiKey": "apiKey", - "SecurityOAuth": "oauth2" - } - }, - "SecurityApiKey": { - "allOf": [ - { - "$ref": "#/definitions/Security" - }, - { - "type": "object", - "properties": { - "name": { - "description": "The name of the header or query parameter i.e. \"X-Api-Key\"", - "type": "string" - }, - "in": { - "description": "Must be either \"header\" or \"query\"", - "type": "string" - } - } - } - ] - }, - "SecurityHttpBasic": { - "allOf": [ - { - "$ref": "#/definitions/Security" - }, - { - "type": "object" - } - ] - }, - "SecurityHttpBearer": { - "allOf": [ - { - "$ref": "#/definitions/Security" - }, - { - "type": "object" - } - ] - }, - "SecurityOAuth": { - "allOf": [ - { - "$ref": "#/definitions/Security" - }, - { - "type": "object", - "properties": { - "tokenUrl": { - "description": "The OAuth2 token endpoint", - "type": "string" - }, - "authorizationUrl": { - "description": "Optional the OAuth2 authorization endpoint", - "type": "string" - }, - "scopes": { - "description": "Optional OAuth2 scopes", - "type": "array", - "items": { - "type": "string" - } - } + "StringPropertyType": "string" } } ] @@ -446,20 +292,10 @@ "description": "A struct represents a class/structure with a fix set of defined properties.", "type": "object", "properties": { - "parent": { - "$ref": "#/definitions/ReferencePropertyType" - }, "base": { "description": "Indicates whether this is a base structure, default is false. If true the structure is used a base type, this means it is not possible to create an instance from this structure.", "type": "boolean" }, - "properties": { - "description": "Contains a map of available properties for this struct.", - "type": "object", - "additionalProperties": { - "$ref": "#/definitions/PropertyType" - } - }, "discriminator": { "description": "Optional the property name of a discriminator property. This should be only used in case this is also a base structure.", "type": "string" @@ -470,6 +306,16 @@ "additionalProperties": { "type": "string" } + }, + "parent": { + "$ref": "#/definitions/ReferencePropertyType" + }, + "properties": { + "description": "Contains a map of available properties for this struct.", + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/PropertyType" + } } } } @@ -479,17 +325,18 @@ "description": "TypeSchema specification", "type": "object", "properties": { - "import": { - "description": "Through the import keyword it is possible to import other TypeSchema documents. It contains a map where the key is the namespace and the value points to a remote document. The value is a URL and a code generator should support at least the following schemes: file, http, https.", + "definitions": { + "description": "", "type": "object", "additionalProperties": { - "type": "string" + "$ref": "#/definitions/DefinitionType" } }, - "definitions": { + "import": { + "description": "Through the import keyword it is possible to import other TypeSchema documents. It contains a map where the key is the namespace and the value points to a remote document. The value is a URL and a code generator should support at least the following schemes: file, http, https.", "type": "object", "additionalProperties": { - "$ref": "#/definitions/DefinitionType" + "type": "string" } }, "root": { @@ -498,30 +345,5 @@ } } } - }, - "allOf": [ - { - "$ref": "#/definitions/TypeSchema" - }, - { - "description": "The TypeAPI Root", - "type": "object", - "properties": { - "baseUrl": { - "description": "Optional the base url of the service, if provided the user does not need to provide a base url for your client", - "type": "string" - }, - "security": { - "$ref": "#/definitions/Security" - }, - "operations": { - "description": "A map of operations which are provided by the API. The key of the operation should be separated by a dot to group operations into logical units i.e. product.getAll or enterprise.product.execute", - "type": "object", - "additionalProperties": { - "$ref": "#/definitions/Operation" - } - } - } - } - ] + } } \ No newline at end of file diff --git a/tests/Generator/resource/kotlin/complex/CollectionDefinitionType.kt b/tests/Generator/resource/kotlin/complex/CollectionDefinitionType.kt index d6b6d8c..0fdb71e 100644 --- a/tests/Generator/resource/kotlin/complex/CollectionDefinitionType.kt +++ b/tests/Generator/resource/kotlin/complex/CollectionDefinitionType.kt @@ -6,5 +6,6 @@ import com.fasterxml.jackson.annotation.* */ open abstract class CollectionDefinitionType : DefinitionType { @JsonProperty("schema") var schema: PropertyType? = null + @JsonProperty("type") var type: String? = null } diff --git a/tests/Generator/resource/kotlin/complex/CollectionPropertyType.kt b/tests/Generator/resource/kotlin/complex/CollectionPropertyType.kt index 88a3569..13a53bc 100644 --- a/tests/Generator/resource/kotlin/complex/CollectionPropertyType.kt +++ b/tests/Generator/resource/kotlin/complex/CollectionPropertyType.kt @@ -6,5 +6,6 @@ import com.fasterxml.jackson.annotation.* */ open abstract class CollectionPropertyType : PropertyType { @JsonProperty("schema") var schema: PropertyType? = null + @JsonProperty("type") var type: String? = null } diff --git a/tests/Generator/resource/kotlin/complex/DefinitionType.kt b/tests/Generator/resource/kotlin/complex/DefinitionType.kt index 43ad800..b46ab66 100644 --- a/tests/Generator/resource/kotlin/complex/DefinitionType.kt +++ b/tests/Generator/resource/kotlin/complex/DefinitionType.kt @@ -5,8 +5,8 @@ import com.fasterxml.jackson.annotation.* * Base definition type */ open abstract class DefinitionType { + @JsonProperty("deprecated") var deprecated: Boolean? = null @JsonProperty("description") var description: String? = null @JsonProperty("type") var type: String? = null - @JsonProperty("deprecated") var deprecated: Boolean? = null } diff --git a/tests/Generator/resource/kotlin/complex/PropertyType.kt b/tests/Generator/resource/kotlin/complex/PropertyType.kt index 6d614aa..3f58922 100644 --- a/tests/Generator/resource/kotlin/complex/PropertyType.kt +++ b/tests/Generator/resource/kotlin/complex/PropertyType.kt @@ -5,9 +5,9 @@ import com.fasterxml.jackson.annotation.* * Base property type */ open abstract class PropertyType { - @JsonProperty("description") var description: String? = null - @JsonProperty("type") var type: String? = null @JsonProperty("deprecated") var deprecated: Boolean? = null + @JsonProperty("description") var description: String? = null @JsonProperty("nullable") var nullable: Boolean? = null + @JsonProperty("type") var type: String? = null } diff --git a/tests/Generator/resource/kotlin/complex/ScalarPropertyType.kt b/tests/Generator/resource/kotlin/complex/ScalarPropertyType.kt index 1ad93ee..35cd0f2 100644 --- a/tests/Generator/resource/kotlin/complex/ScalarPropertyType.kt +++ b/tests/Generator/resource/kotlin/complex/ScalarPropertyType.kt @@ -5,5 +5,6 @@ import com.fasterxml.jackson.annotation.* * Base scalar property type */ open abstract class ScalarPropertyType : PropertyType { + @JsonProperty("type") var type: String? = null } diff --git a/tests/Generator/resource/kotlin/complex/StructDefinitionType.kt b/tests/Generator/resource/kotlin/complex/StructDefinitionType.kt index d11a2ac..ed3d655 100644 --- a/tests/Generator/resource/kotlin/complex/StructDefinitionType.kt +++ b/tests/Generator/resource/kotlin/complex/StructDefinitionType.kt @@ -5,10 +5,10 @@ import com.fasterxml.jackson.annotation.* * A struct represents a class/structure with a fix set of defined properties. */ open class StructDefinitionType : DefinitionType { - @JsonProperty("parent") var parent: ReferencePropertyType? = null @JsonProperty("base") var base: Boolean? = null - @JsonProperty("properties") var properties: HashMap<String, PropertyType>? = null @JsonProperty("discriminator") var discriminator: String? = null @JsonProperty("mapping") var mapping: HashMap<String, String>? = null + @JsonProperty("parent") var parent: ReferencePropertyType? = null + @JsonProperty("properties") var properties: HashMap<String, PropertyType>? = null } diff --git a/tests/Generator/resource/kotlin/complex/TypeSchema.kt b/tests/Generator/resource/kotlin/complex/TypeSchema.kt index 54239e8..05d7086 100644 --- a/tests/Generator/resource/kotlin/complex/TypeSchema.kt +++ b/tests/Generator/resource/kotlin/complex/TypeSchema.kt @@ -5,8 +5,8 @@ import com.fasterxml.jackson.annotation.* * TypeSchema specification */ open class TypeSchema { - @JsonProperty("import") var import: HashMap<String, String>? = null @JsonProperty("definitions") var definitions: HashMap<String, DefinitionType>? = null + @JsonProperty("import") var import: HashMap<String, String>? = null @JsonProperty("root") var root: String? = null } diff --git a/tests/Generator/resource/markdown/markdown_complex.md b/tests/Generator/resource/markdown/markdown_complex.md index 1a1d765..2043d7c 100644 --- a/tests/Generator/resource/markdown/markdown_complex.md +++ b/tests/Generator/resource/markdown/markdown_complex.md @@ -1,94 +1,21 @@ -# Security - -Field | Type | Description ------ | ---- | ----------- -type | String | The global security type of the API must be one of: httpBasic, httpBearer, apiKey or oauth2 - - -# SecurityHttpBasic - -Field | Type | Description ------ | ---- | ----------- - - -# SecurityHttpBearer - -Field | Type | Description ------ | ---- | ----------- - - -# SecurityApiKey - -Field | Type | Description ------ | ---- | ----------- -name | String | The name of the header or query parameter i.e. "X-Api-Key" -in | String | Must be either "header" or "query" - - -# SecurityOAuth - -Field | Type | Description ------ | ---- | ----------- -tokenUrl | String | The OAuth2 token endpoint -authorizationUrl | String | Optional the OAuth2 authorization endpoint -scopes | Array (String) | Optional OAuth2 scopes - - -# Operation - -Field | Type | Description ------ | ---- | ----------- -method | String | The HTTP method which is associated with this operation, must be a valid HTTP method i.e. GET, POST, PUT etc. -path | String | The HTTP path which is associated with this operation. A path can also include variable path fragments i.e. /my/path/:year then you can map the variable year path fragment to a specific argument -return | Response | The return type of this operation. The return has also an assigned HTTP success status code which is by default 200 -arguments | Map (Argument) | All arguments provided to this operation. Each argument is mapped to a location from the HTTP request i.e. query or body -throws | Array (Response) | All exceptional states which can occur in case the operation fails. Each exception is assigned to an HTTP error status code -description | String | A short description of this operation. The generated code will include this description at the method so it is recommend to use simple alphanumeric characters and no new lines -stability | Integer | Indicates the stability of this operation: 0 - Deprecated, 1 - Experimental, 2 - Stable, 3 - Legacy. If not explicit provided the operation is by default experimental. -security | Array (String) | An array of scopes which are required to access this operation -authorization | Boolean | Indicates whether this operation needs authorization, if set to false the client will not send an authorization header, default it is true -tags | Array (String) | Optional an array of tags to group operations - - -# Argument - -Field | Type | Description ------ | ---- | ----------- -in | String | The location where the value can be found either in the path, query, header or body. If you choose path, then your path must have a fitting variable path fragment -schema | PropertyType | -contentType | String | In case the data is not a JSON payload which you can describe with a schema you can select a content type -name | String | Optional the actual path, query or header name. If not provided the key of the argument map is used - - -# Response - -Field | Type | Description ------ | ---- | ----------- -code | Integer | The associated HTTP response code. For error responses it is possible to use the 499, 599 or 999 status code to catch all errors -contentType | String | In case the data is not a JSON payload which you can describe with a schema you can select a content type -schema | PropertyType | - - -# TypeSchema +# PropertyType -TypeSchema specification +Base property type Field | Type | Description ----- | ---- | ----------- -import | Map (String) | Through the import keyword it is possible to import other TypeSchema documents. It contains a map where the key is the namespace and the value points to a remote document. The value is a URL and a code generator should support at least the following schemes: file, http, https. -definitions | Map (DefinitionType) | -root | String | Specifies the root type of your specification. +deprecated | Boolean | +description | String | +nullable | Boolean | +type | String | -# TypeAPI +# AnyPropertyType -The TypeAPI Root +Represents an any value which allows any kind of value Field | Type | Description ----- | ---- | ----------- -baseUrl | String | Optional the base url of the service, if provided the user does not need to provide a base url for your client -security | Security | Describes the authorization mechanism which is used by your API -operations | Map (Operation) | A map of operations which are provided by the API. The key of the operation should be separated by a dot to group operations into logical units i.e. product.getAll or enterprise.product.execute # DefinitionType @@ -97,22 +24,9 @@ Base definition type Field | Type | Description ----- | ---- | ----------- +deprecated | Boolean | description | String | type | String | -deprecated | Boolean | - - -# StructDefinitionType - -A struct represents a class/structure with a fix set of defined properties. - -Field | Type | Description ------ | ---- | ----------- -parent | ReferencePropertyType | Defines a parent type for this structure. Some programming languages like Go do not support the concept of an extends, in this case the code generator simply copies all properties into this structure. -base | Boolean | Indicates whether this is a base structure, default is false. If true the structure is used a base type, this means it is not possible to create an instance from this structure. -properties | Map (PropertyType) | Contains a map of available properties for this struct. -discriminator | String | Optional the property name of a discriminator property. This should be only used in case this is also a base structure. -mapping | Map (String) | In case a discriminator is configured it is required to configure a mapping. The mapping is a map where the key is the type name and the value the actual discriminator type value. # CollectionDefinitionType @@ -122,34 +36,33 @@ Base collection type Field | Type | Description ----- | ---- | ----------- schema | PropertyType | +type | String | -# MapDefinitionType +# ArrayDefinitionType -Represents a map which contains a dynamic set of key value entries of the same type +Represents an array which contains a dynamic list of values of the same type Field | Type | Description ----- | ---- | ----------- -# ArrayDefinitionType +# CollectionPropertyType -Represents an array which contains a dynamic list of values of the same type +Base collection property type Field | Type | Description ----- | ---- | ----------- +schema | PropertyType | +type | String | -# PropertyType +# ArrayPropertyType -Base property type +Represents an array which contains a dynamic list of values of the same type Field | Type | Description ----- | ---- | ----------- -description | String | -type | String | -deprecated | Boolean | -nullable | Boolean | # ScalarPropertyType @@ -158,89 +71,97 @@ Base scalar property type Field | Type | Description ----- | ---- | ----------- +type | String | -# StringPropertyType +# BooleanPropertyType -Represents a string value +Represents a boolean value Field | Type | Description ----- | ---- | ----------- -format | String | Optional describes the format of the string. Supported are the following types: date, date-time and time. A code generator may use a fitting data type to represent such a format, if not supported it should fall back to a string. -# IntegerPropertyType +# GenericPropertyType -Represents an integer value +Represents a generic value which can be replaced with a dynamic type Field | Type | Description ----- | ---- | ----------- +name | String | The name of the generic, it is recommended to use common generic names like T or TValue. These generics can then be replaced on usage with a concrete type through the template property at a reference. -# NumberPropertyType +# IntegerPropertyType -Represents a float value +Represents an integer value Field | Type | Description ----- | ---- | ----------- -# BooleanPropertyType +# MapDefinitionType -Represents a boolean value +Represents a map which contains a dynamic set of key value entries of the same type Field | Type | Description ----- | ---- | ----------- -# CollectionPropertyType +# MapPropertyType -Base collection property type +Represents a map which contains a dynamic set of key value entries of the same type Field | Type | Description ----- | ---- | ----------- -schema | PropertyType | -# MapPropertyType +# NumberPropertyType -Represents a map which contains a dynamic set of key value entries of the same type +Represents a float value Field | Type | Description ----- | ---- | ----------- -# ArrayPropertyType +# ReferencePropertyType -Represents an array which contains a dynamic list of values of the same type +Represents a reference to a definition type Field | Type | Description ----- | ---- | ----------- +target | String | The target type, this must be a key which is available under the definitions keyword. +template | Map (String) | A map where the key is the name of the generic and the value must point to a key under the definitions keyword. This can be used in case the target points to a type which contains generics, then it is possible to replace those generics with a concrete type. -# AnyPropertyType +# StringPropertyType -Represents an any value which allows any kind of value +Represents a string value Field | Type | Description ----- | ---- | ----------- +format | String | Optional describes the format of the string. Supported are the following types: date, date-time and time. A code generator may use a fitting data type to represent such a format, if not supported it should fall back to a string. -# GenericPropertyType +# StructDefinitionType -Represents a generic value which can be replaced with a dynamic type +A struct represents a class/structure with a fix set of defined properties. Field | Type | Description ----- | ---- | ----------- -name | String | The name of the generic, it is recommended to use common generic names like T or TValue. These generics can then be replaced on usage with a concrete type through the template property at a reference. +base | Boolean | Indicates whether this is a base structure, default is false. If true the structure is used a base type, this means it is not possible to create an instance from this structure. +discriminator | String | Optional the property name of a discriminator property. This should be only used in case this is also a base structure. +mapping | Map (String) | In case a discriminator is configured it is required to configure a mapping. The mapping is a map where the key is the type name and the value the actual discriminator type value. +parent | ReferencePropertyType | Defines a parent type for this structure. Some programming languages like Go do not support the concept of an extends, in this case the code generator simply copies all properties into this structure. +properties | Map (PropertyType) | Contains a map of available properties for this struct. -# ReferencePropertyType +# TypeSchema -Represents a reference to a definition type +TypeSchema specification Field | Type | Description ----- | ---- | ----------- -target | String | The target type, this must be a key which is available under the definitions keyword. -template | Map (String) | A map where the key is the name of the generic and the value must point to a key under the definitions keyword. This can be used in case the target points to a type which contains generics, then it is possible to replace those generics with a concrete type. +definitions | Map (DefinitionType) | +import | Map (String) | Through the import keyword it is possible to import other TypeSchema documents. It contains a map where the key is the namespace and the value points to a remote document. The value is a URL and a code generator should support at least the following schemes: file, http, https. +root | String | Specifies the root type of your specification. diff --git a/tests/Generator/resource/php/complex/CollectionDefinitionType.php b/tests/Generator/resource/php/complex/CollectionDefinitionType.php index c290011..ccfa209 100644 --- a/tests/Generator/resource/php/complex/CollectionDefinitionType.php +++ b/tests/Generator/resource/php/complex/CollectionDefinitionType.php @@ -10,12 +10,14 @@ #[Description('Base collection type')] #[Discriminator('type')] -#[DerivedType(MapDefinitionType::class, 'map')] #[DerivedType(ArrayDefinitionType::class, 'array')] +#[DerivedType(MapDefinitionType::class, 'map')] abstract class CollectionDefinitionType extends DefinitionType implements \JsonSerializable, \PSX\Record\RecordableInterface { #[Description('')] protected ?PropertyType $schema = null; + #[Description('')] + protected ?string $type = null; public function setSchema(?PropertyType $schema) : void { $this->schema = $schema; @@ -24,11 +26,20 @@ public function getSchema() : ?PropertyType { return $this->schema; } + public function setType(?string $type) : void + { + $this->type = $type; + } + public function getType() : ?string + { + return $this->type; + } public function toRecord() : \PSX\Record\RecordInterface { /** @var \PSX\Record\Record<mixed> $record */ $record = parent::toRecord(); $record->put('schema', $this->schema); + $record->put('type', $this->type); return $record; } public function jsonSerialize() : object diff --git a/tests/Generator/resource/php/complex/CollectionPropertyType.php b/tests/Generator/resource/php/complex/CollectionPropertyType.php index 24bacc3..4f79054 100644 --- a/tests/Generator/resource/php/complex/CollectionPropertyType.php +++ b/tests/Generator/resource/php/complex/CollectionPropertyType.php @@ -4,13 +4,20 @@ namespace TypeAPI\Model; +use PSX\Schema\Attribute\DerivedType; use PSX\Schema\Attribute\Description; +use PSX\Schema\Attribute\Discriminator; #[Description('Base collection property type')] +#[Discriminator('type')] +#[DerivedType(ArrayPropertyType::class, 'array')] +#[DerivedType(MapPropertyType::class, 'map')] abstract class CollectionPropertyType extends PropertyType implements \JsonSerializable, \PSX\Record\RecordableInterface { #[Description('')] protected ?PropertyType $schema = null; + #[Description('')] + protected ?string $type = null; public function setSchema(?PropertyType $schema) : void { $this->schema = $schema; @@ -19,11 +26,20 @@ public function getSchema() : ?PropertyType { return $this->schema; } + public function setType(?string $type) : void + { + $this->type = $type; + } + public function getType() : ?string + { + return $this->type; + } public function toRecord() : \PSX\Record\RecordInterface { /** @var \PSX\Record\Record<mixed> $record */ $record = parent::toRecord(); $record->put('schema', $this->schema); + $record->put('type', $this->type); return $record; } public function jsonSerialize() : object diff --git a/tests/Generator/resource/php/complex/DefinitionType.php b/tests/Generator/resource/php/complex/DefinitionType.php index 56c041a..8fc3550 100644 --- a/tests/Generator/resource/php/complex/DefinitionType.php +++ b/tests/Generator/resource/php/complex/DefinitionType.php @@ -10,14 +10,25 @@ #[Description('Base definition type')] #[Discriminator('type')] -#[DerivedType(StructDefinitionType::class, 'struct')] -#[DerivedType(MapDefinitionType::class, 'map')] #[DerivedType(ArrayDefinitionType::class, 'array')] +#[DerivedType(MapDefinitionType::class, 'map')] +#[DerivedType(StructDefinitionType::class, 'struct')] abstract class DefinitionType implements \JsonSerializable, \PSX\Record\RecordableInterface { + #[Description('')] + protected ?bool $deprecated = null; + #[Description('')] protected ?string $description = null; + #[Description('')] protected ?string $type = null; - protected ?bool $deprecated = null; + public function setDeprecated(?bool $deprecated) : void + { + $this->deprecated = $deprecated; + } + public function getDeprecated() : ?bool + { + return $this->deprecated; + } public function setDescription(?string $description) : void { $this->description = $description; @@ -34,21 +45,13 @@ public function getType() : ?string { return $this->type; } - public function setDeprecated(?bool $deprecated) : void - { - $this->deprecated = $deprecated; - } - public function getDeprecated() : ?bool - { - return $this->deprecated; - } public function toRecord() : \PSX\Record\RecordInterface { /** @var \PSX\Record\Record<mixed> $record */ $record = new \PSX\Record\Record(); + $record->put('deprecated', $this->deprecated); $record->put('description', $this->description); $record->put('type', $this->type); - $record->put('deprecated', $this->deprecated); return $record; } public function jsonSerialize() : object diff --git a/tests/Generator/resource/php/complex/PropertyType.php b/tests/Generator/resource/php/complex/PropertyType.php index d34e485..07255a7 100644 --- a/tests/Generator/resource/php/complex/PropertyType.php +++ b/tests/Generator/resource/php/complex/PropertyType.php @@ -10,37 +10,25 @@ #[Description('Base property type')] #[Discriminator('type')] -#[DerivedType(StringPropertyType::class, 'string')] -#[DerivedType(IntegerPropertyType::class, 'integer')] -#[DerivedType(NumberPropertyType::class, 'number')] -#[DerivedType(BooleanPropertyType::class, 'boolean')] -#[DerivedType(MapPropertyType::class, 'map')] -#[DerivedType(ArrayPropertyType::class, 'array')] #[DerivedType(AnyPropertyType::class, 'any')] +#[DerivedType(ArrayPropertyType::class, 'array')] +#[DerivedType(BooleanPropertyType::class, 'boolean')] #[DerivedType(GenericPropertyType::class, 'generic')] +#[DerivedType(IntegerPropertyType::class, 'integer')] +#[DerivedType(MapPropertyType::class, 'map')] +#[DerivedType(NumberPropertyType::class, 'number')] #[DerivedType(ReferencePropertyType::class, 'reference')] +#[DerivedType(StringPropertyType::class, 'string')] abstract class PropertyType implements \JsonSerializable, \PSX\Record\RecordableInterface { - protected ?string $description = null; - protected ?string $type = null; + #[Description('')] protected ?bool $deprecated = null; + #[Description('')] + protected ?string $description = null; + #[Description('')] protected ?bool $nullable = null; - public function setDescription(?string $description) : void - { - $this->description = $description; - } - public function getDescription() : ?string - { - return $this->description; - } - public function setType(?string $type) : void - { - $this->type = $type; - } - public function getType() : ?string - { - return $this->type; - } + #[Description('')] + protected ?string $type = null; public function setDeprecated(?bool $deprecated) : void { $this->deprecated = $deprecated; @@ -49,6 +37,14 @@ public function getDeprecated() : ?bool { return $this->deprecated; } + public function setDescription(?string $description) : void + { + $this->description = $description; + } + public function getDescription() : ?string + { + return $this->description; + } public function setNullable(?bool $nullable) : void { $this->nullable = $nullable; @@ -57,14 +53,22 @@ public function getNullable() : ?bool { return $this->nullable; } + public function setType(?string $type) : void + { + $this->type = $type; + } + public function getType() : ?string + { + return $this->type; + } public function toRecord() : \PSX\Record\RecordInterface { /** @var \PSX\Record\Record<mixed> $record */ $record = new \PSX\Record\Record(); - $record->put('description', $this->description); - $record->put('type', $this->type); $record->put('deprecated', $this->deprecated); + $record->put('description', $this->description); $record->put('nullable', $this->nullable); + $record->put('type', $this->type); return $record; } public function jsonSerialize() : object diff --git a/tests/Generator/resource/php/complex/ScalarPropertyType.php b/tests/Generator/resource/php/complex/ScalarPropertyType.php index 15ae3b5..9caa20a 100644 --- a/tests/Generator/resource/php/complex/ScalarPropertyType.php +++ b/tests/Generator/resource/php/complex/ScalarPropertyType.php @@ -10,11 +10,32 @@ #[Description('Base scalar property type')] #[Discriminator('type')] -#[DerivedType(StringPropertyType::class, 'string')] +#[DerivedType(BooleanPropertyType::class, 'boolean')] #[DerivedType(IntegerPropertyType::class, 'integer')] #[DerivedType(NumberPropertyType::class, 'number')] -#[DerivedType(BooleanPropertyType::class, 'boolean')] +#[DerivedType(StringPropertyType::class, 'string')] abstract class ScalarPropertyType extends PropertyType implements \JsonSerializable, \PSX\Record\RecordableInterface { + #[Description('')] + protected ?string $type = null; + public function setType(?string $type) : void + { + $this->type = $type; + } + public function getType() : ?string + { + return $this->type; + } + public function toRecord() : \PSX\Record\RecordInterface + { + /** @var \PSX\Record\Record<mixed> $record */ + $record = parent::toRecord(); + $record->put('type', $this->type); + return $record; + } + public function jsonSerialize() : object + { + return (object) $this->toRecord()->getAll(); + } } diff --git a/tests/Generator/resource/php/complex/StructDefinitionType.php b/tests/Generator/resource/php/complex/StructDefinitionType.php index 9f80b67..102c78b 100644 --- a/tests/Generator/resource/php/complex/StructDefinitionType.php +++ b/tests/Generator/resource/php/complex/StructDefinitionType.php @@ -9,15 +9,8 @@ #[Description('A struct represents a class/structure with a fix set of defined properties.')] class StructDefinitionType extends DefinitionType implements \JsonSerializable, \PSX\Record\RecordableInterface { - #[Description('Defines a parent type for this structure. Some programming languages like Go do not support the concept of an extends, in this case the code generator simply copies all properties into this structure.')] - protected ?ReferencePropertyType $parent = null; #[Description('Indicates whether this is a base structure, default is false. If true the structure is used a base type, this means it is not possible to create an instance from this structure.')] protected ?bool $base = null; - /** - * @var \PSX\Record\Record<PropertyType>|null - */ - #[Description('Contains a map of available properties for this struct.')] - protected ?\PSX\Record\Record $properties = null; #[Description('Optional the property name of a discriminator property. This should be only used in case this is also a base structure.')] protected ?string $discriminator = null; /** @@ -25,14 +18,13 @@ class StructDefinitionType extends DefinitionType implements \JsonSerializable, */ #[Description('In case a discriminator is configured it is required to configure a mapping. The mapping is a map where the key is the type name and the value the actual discriminator type value.')] protected ?\PSX\Record\Record $mapping = null; - public function setParent(?ReferencePropertyType $parent) : void - { - $this->parent = $parent; - } - public function getParent() : ?ReferencePropertyType - { - return $this->parent; - } + #[Description('Defines a parent type for this structure. Some programming languages like Go do not support the concept of an extends, in this case the code generator simply copies all properties into this structure.')] + protected ?ReferencePropertyType $parent = null; + /** + * @var \PSX\Record\Record<PropertyType>|null + */ + #[Description('Contains a map of available properties for this struct.')] + protected ?\PSX\Record\Record $properties = null; public function setBase(?bool $base) : void { $this->base = $base; @@ -41,20 +33,6 @@ public function getBase() : ?bool { return $this->base; } - /** - * @param \PSX\Record\Record<PropertyType>|null $properties - */ - public function setProperties(?\PSX\Record\Record $properties) : void - { - $this->properties = $properties; - } - /** - * @return \PSX\Record\Record<PropertyType>|null - */ - public function getProperties() : ?\PSX\Record\Record - { - return $this->properties; - } public function setDiscriminator(?string $discriminator) : void { $this->discriminator = $discriminator; @@ -77,15 +55,37 @@ public function getMapping() : ?\PSX\Record\Record { return $this->mapping; } + public function setParent(?ReferencePropertyType $parent) : void + { + $this->parent = $parent; + } + public function getParent() : ?ReferencePropertyType + { + return $this->parent; + } + /** + * @param \PSX\Record\Record<PropertyType>|null $properties + */ + public function setProperties(?\PSX\Record\Record $properties) : void + { + $this->properties = $properties; + } + /** + * @return \PSX\Record\Record<PropertyType>|null + */ + public function getProperties() : ?\PSX\Record\Record + { + return $this->properties; + } public function toRecord() : \PSX\Record\RecordInterface { /** @var \PSX\Record\Record<mixed> $record */ $record = parent::toRecord(); - $record->put('parent', $this->parent); $record->put('base', $this->base); - $record->put('properties', $this->properties); $record->put('discriminator', $this->discriminator); $record->put('mapping', $this->mapping); + $record->put('parent', $this->parent); + $record->put('properties', $this->properties); return $record; } public function jsonSerialize() : object diff --git a/tests/Generator/resource/php/complex/TypeSchema.php b/tests/Generator/resource/php/complex/TypeSchema.php index 20f7e60..80a54cd 100644 --- a/tests/Generator/resource/php/complex/TypeSchema.php +++ b/tests/Generator/resource/php/complex/TypeSchema.php @@ -9,44 +9,45 @@ #[Description('TypeSchema specification')] class TypeSchema implements \JsonSerializable, \PSX\Record\RecordableInterface { + /** + * @var \PSX\Record\Record<DefinitionType>|null + */ + #[Description('')] + protected ?\PSX\Record\Record $definitions = null; /** * @var \PSX\Record\Record<string>|null */ #[Description('Through the import keyword it is possible to import other TypeSchema documents. It contains a map where the key is the namespace and the value points to a remote document. The value is a URL and a code generator should support at least the following schemes: file, http, https.')] protected ?\PSX\Record\Record $import = null; - /** - * @var \PSX\Record\Record<DefinitionType>|null - */ - protected ?\PSX\Record\Record $definitions = null; #[Description('Specifies the root type of your specification.')] protected ?string $root = null; /** - * @param \PSX\Record\Record<string>|null $import + * @param \PSX\Record\Record<DefinitionType>|null $definitions */ - public function setImport(?\PSX\Record\Record $import) : void + public function setDefinitions(?\PSX\Record\Record $definitions) : void { - $this->import = $import; + $this->definitions = $definitions; } /** - * @return \PSX\Record\Record<string>|null + * @return \PSX\Record\Record<DefinitionType>|null */ - public function getImport() : ?\PSX\Record\Record + public function getDefinitions() : ?\PSX\Record\Record { - return $this->import; + return $this->definitions; } /** - * @param \PSX\Record\Record<DefinitionType>|null $definitions + * @param \PSX\Record\Record<string>|null $import */ - public function setDefinitions(?\PSX\Record\Record $definitions) : void + public function setImport(?\PSX\Record\Record $import) : void { - $this->definitions = $definitions; + $this->import = $import; } /** - * @return \PSX\Record\Record<DefinitionType>|null + * @return \PSX\Record\Record<string>|null */ - public function getDefinitions() : ?\PSX\Record\Record + public function getImport() : ?\PSX\Record\Record { - return $this->definitions; + return $this->import; } public function setRoot(?string $root) : void { @@ -60,8 +61,8 @@ public function toRecord() : \PSX\Record\RecordInterface { /** @var \PSX\Record\Record<mixed> $record */ $record = new \PSX\Record\Record(); - $record->put('import', $this->import); $record->put('definitions', $this->definitions); + $record->put('import', $this->import); $record->put('root', $this->root); return $record; } diff --git a/tests/Generator/resource/python/complex/collection_definition_type.py b/tests/Generator/resource/python/complex/collection_definition_type.py index 00e80c7..a79510d 100644 --- a/tests/Generator/resource/python/complex/collection_definition_type.py +++ b/tests/Generator/resource/python/complex/collection_definition_type.py @@ -1,25 +1,26 @@ from pydantic import BaseModel, Field, GetCoreSchemaHandler from pydantic_core import CoreSchema, core_schema from typing import Any, Dict, Generic, List, Optional, TypeVar -from .map_definition_type import MapDefinitionType from .array_definition_type import ArrayDefinitionType +from .map_definition_type import MapDefinitionType from .definition_type import DefinitionType from .property_type import PropertyType -from .string_property_type import StringPropertyType -from .integer_property_type import IntegerPropertyType -from .number_property_type import NumberPropertyType -from .boolean_property_type import BooleanPropertyType -from .map_property_type import MapPropertyType -from .array_property_type import ArrayPropertyType from .any_property_type import AnyPropertyType +from .array_property_type import ArrayPropertyType +from .boolean_property_type import BooleanPropertyType from .generic_property_type import GenericPropertyType +from .integer_property_type import IntegerPropertyType +from .map_property_type import MapPropertyType +from .number_property_type import NumberPropertyType from .reference_property_type import ReferencePropertyType +from .string_property_type import StringPropertyType # Base collection type class CollectionDefinitionType(DefinitionType): - schema_: Optional[Annotated[Union[Annotated[StringPropertyType, Tag('string')], Annotated[IntegerPropertyType, Tag('integer')], Annotated[NumberPropertyType, Tag('number')], Annotated[BooleanPropertyType, Tag('boolean')], Annotated[MapPropertyType, Tag('map')], Annotated[ArrayPropertyType, Tag('array')], Annotated[AnyPropertyType, Tag('any')], Annotated[GenericPropertyType, Tag('generic')], Annotated[ReferencePropertyType, Tag('reference')]], Field(discriminator='type')] + schema_: Optional[Annotated[Union[Annotated[AnyPropertyType, Tag('any')], Annotated[ArrayPropertyType, Tag('array')], Annotated[BooleanPropertyType, Tag('boolean')], Annotated[GenericPropertyType, Tag('generic')], Annotated[IntegerPropertyType, Tag('integer')], Annotated[MapPropertyType, Tag('map')], Annotated[NumberPropertyType, Tag('number')], Annotated[ReferencePropertyType, Tag('reference')], Annotated[StringPropertyType, Tag('string')]], Field(discriminator='type')] ] = Field(default=None, alias="schema") + type: Optional[str] = Field(default=None, alias="type") pass diff --git a/tests/Generator/resource/python/complex/collection_property_type.py b/tests/Generator/resource/python/complex/collection_property_type.py index 5ddb1ea..6653fad 100644 --- a/tests/Generator/resource/python/complex/collection_property_type.py +++ b/tests/Generator/resource/python/complex/collection_property_type.py @@ -1,22 +1,25 @@ from pydantic import BaseModel, Field, GetCoreSchemaHandler from pydantic_core import CoreSchema, core_schema from typing import Any, Dict, Generic, List, Optional, TypeVar -from .property_type import PropertyType -from .string_property_type import StringPropertyType -from .integer_property_type import IntegerPropertyType -from .number_property_type import NumberPropertyType -from .boolean_property_type import BooleanPropertyType -from .map_property_type import MapPropertyType from .array_property_type import ArrayPropertyType +from .map_property_type import MapPropertyType +from .property_type import PropertyType from .any_property_type import AnyPropertyType +from .array_property_type import ArrayPropertyType +from .boolean_property_type import BooleanPropertyType from .generic_property_type import GenericPropertyType +from .integer_property_type import IntegerPropertyType +from .map_property_type import MapPropertyType +from .number_property_type import NumberPropertyType from .reference_property_type import ReferencePropertyType +from .string_property_type import StringPropertyType # Base collection property type class CollectionPropertyType(PropertyType): - schema_: Optional[Annotated[Union[Annotated[StringPropertyType, Tag('string')], Annotated[IntegerPropertyType, Tag('integer')], Annotated[NumberPropertyType, Tag('number')], Annotated[BooleanPropertyType, Tag('boolean')], Annotated[MapPropertyType, Tag('map')], Annotated[ArrayPropertyType, Tag('array')], Annotated[AnyPropertyType, Tag('any')], Annotated[GenericPropertyType, Tag('generic')], Annotated[ReferencePropertyType, Tag('reference')]], Field(discriminator='type')] + schema_: Optional[Annotated[Union[Annotated[AnyPropertyType, Tag('any')], Annotated[ArrayPropertyType, Tag('array')], Annotated[BooleanPropertyType, Tag('boolean')], Annotated[GenericPropertyType, Tag('generic')], Annotated[IntegerPropertyType, Tag('integer')], Annotated[MapPropertyType, Tag('map')], Annotated[NumberPropertyType, Tag('number')], Annotated[ReferencePropertyType, Tag('reference')], Annotated[StringPropertyType, Tag('string')]], Field(discriminator='type')] ] = Field(default=None, alias="schema") + type: Optional[str] = Field(default=None, alias="type") pass diff --git a/tests/Generator/resource/python/complex/definition_type.py b/tests/Generator/resource/python/complex/definition_type.py index bf077a3..2a0deda 100644 --- a/tests/Generator/resource/python/complex/definition_type.py +++ b/tests/Generator/resource/python/complex/definition_type.py @@ -1,16 +1,16 @@ from pydantic import BaseModel, Field, GetCoreSchemaHandler from pydantic_core import CoreSchema, core_schema from typing import Any, Dict, Generic, List, Optional, TypeVar -from .struct_definition_type import StructDefinitionType -from .map_definition_type import MapDefinitionType from .array_definition_type import ArrayDefinitionType +from .map_definition_type import MapDefinitionType +from .struct_definition_type import StructDefinitionType # Base definition type class DefinitionType(BaseModel): + deprecated: Optional[bool] = Field(default=None, alias="deprecated") description: Optional[str] = Field(default=None, alias="description") type: Optional[str] = Field(default=None, alias="type") - deprecated: Optional[bool] = Field(default=None, alias="deprecated") pass diff --git a/tests/Generator/resource/python/complex/property_type.py b/tests/Generator/resource/python/complex/property_type.py index 19e7fbb..dfc44b5 100644 --- a/tests/Generator/resource/python/complex/property_type.py +++ b/tests/Generator/resource/python/complex/property_type.py @@ -1,23 +1,23 @@ from pydantic import BaseModel, Field, GetCoreSchemaHandler from pydantic_core import CoreSchema, core_schema from typing import Any, Dict, Generic, List, Optional, TypeVar -from .string_property_type import StringPropertyType -from .integer_property_type import IntegerPropertyType -from .number_property_type import NumberPropertyType -from .boolean_property_type import BooleanPropertyType -from .map_property_type import MapPropertyType -from .array_property_type import ArrayPropertyType from .any_property_type import AnyPropertyType +from .array_property_type import ArrayPropertyType +from .boolean_property_type import BooleanPropertyType from .generic_property_type import GenericPropertyType +from .integer_property_type import IntegerPropertyType +from .map_property_type import MapPropertyType +from .number_property_type import NumberPropertyType from .reference_property_type import ReferencePropertyType +from .string_property_type import StringPropertyType # Base property type class PropertyType(BaseModel): - description: Optional[str] = Field(default=None, alias="description") - type: Optional[str] = Field(default=None, alias="type") deprecated: Optional[bool] = Field(default=None, alias="deprecated") + description: Optional[str] = Field(default=None, alias="description") nullable: Optional[bool] = Field(default=None, alias="nullable") + type: Optional[str] = Field(default=None, alias="type") pass diff --git a/tests/Generator/resource/python/complex/scalar_property_type.py b/tests/Generator/resource/python/complex/scalar_property_type.py index d9f2bed..c7e3997 100644 --- a/tests/Generator/resource/python/complex/scalar_property_type.py +++ b/tests/Generator/resource/python/complex/scalar_property_type.py @@ -1,15 +1,16 @@ from pydantic import BaseModel, Field, GetCoreSchemaHandler from pydantic_core import CoreSchema, core_schema from typing import Any, Dict, Generic, List, Optional, TypeVar -from .string_property_type import StringPropertyType +from .boolean_property_type import BooleanPropertyType from .integer_property_type import IntegerPropertyType from .number_property_type import NumberPropertyType -from .boolean_property_type import BooleanPropertyType +from .string_property_type import StringPropertyType from .property_type import PropertyType # Base scalar property type class ScalarPropertyType(PropertyType): + type: Optional[str] = Field(default=None, alias="type") pass diff --git a/tests/Generator/resource/python/complex/struct_definition_type.py b/tests/Generator/resource/python/complex/struct_definition_type.py index 45b2dc1..a294832 100644 --- a/tests/Generator/resource/python/complex/struct_definition_type.py +++ b/tests/Generator/resource/python/complex/struct_definition_type.py @@ -8,11 +8,11 @@ # A struct represents a class/structure with a fix set of defined properties. class StructDefinitionType(DefinitionType): - parent: Optional[ReferencePropertyType] = Field(default=None, alias="parent") base: Optional[bool] = Field(default=None, alias="base") - properties: Optional[Dict[str, PropertyType]] = Field(default=None, alias="properties") discriminator: Optional[str] = Field(default=None, alias="discriminator") mapping: Optional[Dict[str, str]] = Field(default=None, alias="mapping") + parent: Optional[ReferencePropertyType] = Field(default=None, alias="parent") + properties: Optional[Dict[str, PropertyType]] = Field(default=None, alias="properties") pass diff --git a/tests/Generator/resource/python/complex/type_schema.py b/tests/Generator/resource/python/complex/type_schema.py index 566ee32..faac508 100644 --- a/tests/Generator/resource/python/complex/type_schema.py +++ b/tests/Generator/resource/python/complex/type_schema.py @@ -6,8 +6,8 @@ # TypeSchema specification class TypeSchema(BaseModel): - import_: Optional[Dict[str, str]] = Field(default=None, alias="import") definitions: Optional[Dict[str, DefinitionType]] = Field(default=None, alias="definitions") + import_: Optional[Dict[str, str]] = Field(default=None, alias="import") root: Optional[str] = Field(default=None, alias="root") pass diff --git a/tests/Generator/resource/ruby/complex/collection_definition_type.rb b/tests/Generator/resource/ruby/complex/collection_definition_type.rb index 6aaf208..849c1d7 100644 --- a/tests/Generator/resource/ruby/complex/collection_definition_type.rb +++ b/tests/Generator/resource/ruby/complex/collection_definition_type.rb @@ -2,10 +2,11 @@ # Base collection type class CollectionDefinitionType extend DefinitionType - attr_accessor :schema + attr_accessor :schema, :type - def initialize(schema) + def initialize(schema, type) @schema = schema + @type = type end end diff --git a/tests/Generator/resource/ruby/complex/collection_property_type.rb b/tests/Generator/resource/ruby/complex/collection_property_type.rb index 57c4504..d8ac514 100644 --- a/tests/Generator/resource/ruby/complex/collection_property_type.rb +++ b/tests/Generator/resource/ruby/complex/collection_property_type.rb @@ -2,10 +2,11 @@ # Base collection property type class CollectionPropertyType extend PropertyType - attr_accessor :schema + attr_accessor :schema, :type - def initialize(schema) + def initialize(schema, type) @schema = schema + @type = type end end diff --git a/tests/Generator/resource/ruby/complex/definition_type.rb b/tests/Generator/resource/ruby/complex/definition_type.rb index a8fc01d..64fd392 100644 --- a/tests/Generator/resource/ruby/complex/definition_type.rb +++ b/tests/Generator/resource/ruby/complex/definition_type.rb @@ -1,12 +1,12 @@ # Base definition type class DefinitionType - attr_accessor :description, :type, :deprecated + attr_accessor :deprecated, :description, :type - def initialize(description, type, deprecated) + def initialize(deprecated, description, type) + @deprecated = deprecated @description = description @type = type - @deprecated = deprecated end end diff --git a/tests/Generator/resource/ruby/complex/property_type.rb b/tests/Generator/resource/ruby/complex/property_type.rb index a8c6cb0..93966b1 100644 --- a/tests/Generator/resource/ruby/complex/property_type.rb +++ b/tests/Generator/resource/ruby/complex/property_type.rb @@ -1,13 +1,13 @@ # Base property type class PropertyType - attr_accessor :description, :type, :deprecated, :nullable + attr_accessor :deprecated, :description, :nullable, :type - def initialize(description, type, deprecated, nullable) - @description = description - @type = type + def initialize(deprecated, description, nullable, type) @deprecated = deprecated + @description = description @nullable = nullable + @type = type end end diff --git a/tests/Generator/resource/ruby/complex/scalar_property_type.rb b/tests/Generator/resource/ruby/complex/scalar_property_type.rb index 3da2963..6424343 100644 --- a/tests/Generator/resource/ruby/complex/scalar_property_type.rb +++ b/tests/Generator/resource/ruby/complex/scalar_property_type.rb @@ -2,8 +2,10 @@ # Base scalar property type class ScalarPropertyType extend PropertyType + attr_accessor :type - def initialize() + def initialize(type) + @type = type end end diff --git a/tests/Generator/resource/ruby/complex/struct_definition_type.rb b/tests/Generator/resource/ruby/complex/struct_definition_type.rb index 85bd2d3..4ca8cb0 100644 --- a/tests/Generator/resource/ruby/complex/struct_definition_type.rb +++ b/tests/Generator/resource/ruby/complex/struct_definition_type.rb @@ -2,14 +2,14 @@ # A struct represents a class/structure with a fix set of defined properties. class StructDefinitionType extend DefinitionType - attr_accessor :parent, :base, :properties, :discriminator, :mapping + attr_accessor :base, :discriminator, :mapping, :parent, :properties - def initialize(parent, base, properties, discriminator, mapping) - @parent = parent + def initialize(base, discriminator, mapping, parent, properties) @base = base - @properties = properties @discriminator = discriminator @mapping = mapping + @parent = parent + @properties = properties end end diff --git a/tests/Generator/resource/ruby/complex/type_schema.rb b/tests/Generator/resource/ruby/complex/type_schema.rb index 4506ef9..8caac75 100644 --- a/tests/Generator/resource/ruby/complex/type_schema.rb +++ b/tests/Generator/resource/ruby/complex/type_schema.rb @@ -1,11 +1,11 @@ # TypeSchema specification class TypeSchema - attr_accessor :import, :definitions, :root + attr_accessor :definitions, :import, :root - def initialize(import, definitions, root) - @import = import + def initialize(definitions, import, root) @definitions = definitions + @import = import @root = root end end diff --git a/tests/Generator/resource/rust/complex/any_property_type.rs b/tests/Generator/resource/rust/complex/any_property_type.rs index f0fe221..68a0179 100644 --- a/tests/Generator/resource/rust/complex/any_property_type.rs +++ b/tests/Generator/resource/rust/complex/any_property_type.rs @@ -4,17 +4,17 @@ use property_type::PropertyType; // Represents an any value which allows any kind of value #[derive(Serialize, Deserialize)] pub struct AnyPropertyType { - #[serde(rename = "description")] - description: Option<String>, - - #[serde(rename = "type")] - _type: Option<String>, - #[serde(rename = "deprecated")] deprecated: Option<bool>, + #[serde(rename = "description")] + description: Option<String>, + #[serde(rename = "nullable")] nullable: Option<bool>, + #[serde(rename = "type")] + _type: Option<String>, + } diff --git a/tests/Generator/resource/rust/complex/array_definition_type.rs b/tests/Generator/resource/rust/complex/array_definition_type.rs index bd0baf0..4c1d034 100644 --- a/tests/Generator/resource/rust/complex/array_definition_type.rs +++ b/tests/Generator/resource/rust/complex/array_definition_type.rs @@ -5,8 +5,8 @@ use property_type::PropertyType; // Represents an array which contains a dynamic list of values of the same type #[derive(Serialize, Deserialize)] pub struct ArrayDefinitionType { - #[serde(rename = "description")] - description: Option<String>, + #[serde(rename = "schema")] + schema: Option<PropertyType>, #[serde(rename = "type")] _type: Option<String>, @@ -14,8 +14,8 @@ pub struct ArrayDefinitionType { #[serde(rename = "deprecated")] deprecated: Option<bool>, - #[serde(rename = "schema")] - schema: Option<PropertyType>, + #[serde(rename = "description")] + description: Option<String>, } diff --git a/tests/Generator/resource/rust/complex/array_property_type.rs b/tests/Generator/resource/rust/complex/array_property_type.rs index 6e51ad0..10910ed 100644 --- a/tests/Generator/resource/rust/complex/array_property_type.rs +++ b/tests/Generator/resource/rust/complex/array_property_type.rs @@ -5,8 +5,8 @@ use property_type::PropertyType; // Represents an array which contains a dynamic list of values of the same type #[derive(Serialize, Deserialize)] pub struct ArrayPropertyType { - #[serde(rename = "description")] - description: Option<String>, + #[serde(rename = "schema")] + schema: Option<PropertyType>, #[serde(rename = "type")] _type: Option<String>, @@ -14,11 +14,11 @@ pub struct ArrayPropertyType { #[serde(rename = "deprecated")] deprecated: Option<bool>, + #[serde(rename = "description")] + description: Option<String>, + #[serde(rename = "nullable")] nullable: Option<bool>, - #[serde(rename = "schema")] - schema: Option<PropertyType>, - } diff --git a/tests/Generator/resource/rust/complex/boolean_property_type.rs b/tests/Generator/resource/rust/complex/boolean_property_type.rs index d755845..81fdf92 100644 --- a/tests/Generator/resource/rust/complex/boolean_property_type.rs +++ b/tests/Generator/resource/rust/complex/boolean_property_type.rs @@ -4,15 +4,15 @@ use scalar_property_type::ScalarPropertyType; // Represents a boolean value #[derive(Serialize, Deserialize)] pub struct BooleanPropertyType { - #[serde(rename = "description")] - description: Option<String>, - #[serde(rename = "type")] _type: Option<String>, #[serde(rename = "deprecated")] deprecated: Option<bool>, + #[serde(rename = "description")] + description: Option<String>, + #[serde(rename = "nullable")] nullable: Option<bool>, diff --git a/tests/Generator/resource/rust/complex/collection_definition_type.rs b/tests/Generator/resource/rust/complex/collection_definition_type.rs index 5f4eea7..041903b 100644 --- a/tests/Generator/resource/rust/complex/collection_definition_type.rs +++ b/tests/Generator/resource/rust/complex/collection_definition_type.rs @@ -1,21 +1,21 @@ use serde::{Serialize, Deserialize}; -use map_definition_type::MapDefinitionType; use array_definition_type::ArrayDefinitionType; +use map_definition_type::MapDefinitionType; use definition_type::DefinitionType; use property_type::PropertyType; // Base collection type #[derive(Serialize, Deserialize)] pub struct CollectionDefinitionType { + #[serde(rename = "deprecated")] + deprecated: Option<bool>, + #[serde(rename = "description")] description: Option<String>, #[serde(rename = "type")] _type: Option<String>, - #[serde(rename = "deprecated")] - deprecated: Option<bool>, - #[serde(rename = "schema")] schema: Option<PropertyType>, diff --git a/tests/Generator/resource/rust/complex/collection_property_type.rs b/tests/Generator/resource/rust/complex/collection_property_type.rs index 51f49dc..cdf6c76 100644 --- a/tests/Generator/resource/rust/complex/collection_property_type.rs +++ b/tests/Generator/resource/rust/complex/collection_property_type.rs @@ -1,21 +1,23 @@ use serde::{Serialize, Deserialize}; +use array_property_type::ArrayPropertyType; +use map_property_type::MapPropertyType; use property_type::PropertyType; // Base collection property type #[derive(Serialize, Deserialize)] pub struct CollectionPropertyType { - #[serde(rename = "description")] - description: Option<String>, - - #[serde(rename = "type")] - _type: Option<String>, - #[serde(rename = "deprecated")] deprecated: Option<bool>, + #[serde(rename = "description")] + description: Option<String>, + #[serde(rename = "nullable")] nullable: Option<bool>, + #[serde(rename = "type")] + _type: Option<String>, + #[serde(rename = "schema")] schema: Option<PropertyType>, diff --git a/tests/Generator/resource/rust/complex/definition_type.rs b/tests/Generator/resource/rust/complex/definition_type.rs index 262fc7e..61047c9 100644 --- a/tests/Generator/resource/rust/complex/definition_type.rs +++ b/tests/Generator/resource/rust/complex/definition_type.rs @@ -1,19 +1,19 @@ use serde::{Serialize, Deserialize}; -use struct_definition_type::StructDefinitionType; -use map_definition_type::MapDefinitionType; use array_definition_type::ArrayDefinitionType; +use map_definition_type::MapDefinitionType; +use struct_definition_type::StructDefinitionType; // Base definition type #[derive(Serialize, Deserialize)] pub struct DefinitionType { + #[serde(rename = "deprecated")] + deprecated: Option<bool>, + #[serde(rename = "description")] description: Option<String>, #[serde(rename = "type")] _type: Option<String>, - #[serde(rename = "deprecated")] - deprecated: Option<bool>, - } diff --git a/tests/Generator/resource/rust/complex/generic_property_type.rs b/tests/Generator/resource/rust/complex/generic_property_type.rs index a36004b..0d62d4a 100644 --- a/tests/Generator/resource/rust/complex/generic_property_type.rs +++ b/tests/Generator/resource/rust/complex/generic_property_type.rs @@ -4,18 +4,18 @@ use property_type::PropertyType; // Represents a generic value which can be replaced with a dynamic type #[derive(Serialize, Deserialize)] pub struct GenericPropertyType { - #[serde(rename = "description")] - description: Option<String>, - - #[serde(rename = "type")] - _type: Option<String>, - #[serde(rename = "deprecated")] deprecated: Option<bool>, + #[serde(rename = "description")] + description: Option<String>, + #[serde(rename = "nullable")] nullable: Option<bool>, + #[serde(rename = "type")] + _type: Option<String>, + #[serde(rename = "name")] name: Option<String>, diff --git a/tests/Generator/resource/rust/complex/integer_property_type.rs b/tests/Generator/resource/rust/complex/integer_property_type.rs index 53f6a71..fbe4210 100644 --- a/tests/Generator/resource/rust/complex/integer_property_type.rs +++ b/tests/Generator/resource/rust/complex/integer_property_type.rs @@ -4,15 +4,15 @@ use scalar_property_type::ScalarPropertyType; // Represents an integer value #[derive(Serialize, Deserialize)] pub struct IntegerPropertyType { - #[serde(rename = "description")] - description: Option<String>, - #[serde(rename = "type")] _type: Option<String>, #[serde(rename = "deprecated")] deprecated: Option<bool>, + #[serde(rename = "description")] + description: Option<String>, + #[serde(rename = "nullable")] nullable: Option<bool>, diff --git a/tests/Generator/resource/rust/complex/map_definition_type.rs b/tests/Generator/resource/rust/complex/map_definition_type.rs index 280c529..ff0b2e5 100644 --- a/tests/Generator/resource/rust/complex/map_definition_type.rs +++ b/tests/Generator/resource/rust/complex/map_definition_type.rs @@ -5,15 +5,15 @@ use property_type::PropertyType; // Represents a map which contains a dynamic set of key value entries of the same type #[derive(Serialize, Deserialize)] pub struct MapDefinitionType { + #[serde(rename = "deprecated")] + deprecated: Option<bool>, + #[serde(rename = "description")] description: Option<String>, #[serde(rename = "type")] _type: Option<String>, - #[serde(rename = "deprecated")] - deprecated: Option<bool>, - #[serde(rename = "schema")] schema: Option<PropertyType>, diff --git a/tests/Generator/resource/rust/complex/map_property_type.rs b/tests/Generator/resource/rust/complex/map_property_type.rs index 99b0346..7d496e2 100644 --- a/tests/Generator/resource/rust/complex/map_property_type.rs +++ b/tests/Generator/resource/rust/complex/map_property_type.rs @@ -5,18 +5,18 @@ use property_type::PropertyType; // Represents a map which contains a dynamic set of key value entries of the same type #[derive(Serialize, Deserialize)] pub struct MapPropertyType { - #[serde(rename = "description")] - description: Option<String>, - - #[serde(rename = "type")] - _type: Option<String>, - #[serde(rename = "deprecated")] deprecated: Option<bool>, + #[serde(rename = "description")] + description: Option<String>, + #[serde(rename = "nullable")] nullable: Option<bool>, + #[serde(rename = "type")] + _type: Option<String>, + #[serde(rename = "schema")] schema: Option<PropertyType>, diff --git a/tests/Generator/resource/rust/complex/number_property_type.rs b/tests/Generator/resource/rust/complex/number_property_type.rs index 907f40a..563a175 100644 --- a/tests/Generator/resource/rust/complex/number_property_type.rs +++ b/tests/Generator/resource/rust/complex/number_property_type.rs @@ -4,15 +4,15 @@ use scalar_property_type::ScalarPropertyType; // Represents a float value #[derive(Serialize, Deserialize)] pub struct NumberPropertyType { - #[serde(rename = "description")] - description: Option<String>, - #[serde(rename = "type")] _type: Option<String>, #[serde(rename = "deprecated")] deprecated: Option<bool>, + #[serde(rename = "description")] + description: Option<String>, + #[serde(rename = "nullable")] nullable: Option<bool>, diff --git a/tests/Generator/resource/rust/complex/property_type.rs b/tests/Generator/resource/rust/complex/property_type.rs index f5acdd6..9c6562c 100644 --- a/tests/Generator/resource/rust/complex/property_type.rs +++ b/tests/Generator/resource/rust/complex/property_type.rs @@ -1,28 +1,28 @@ use serde::{Serialize, Deserialize}; -use string_property_type::StringPropertyType; -use integer_property_type::IntegerPropertyType; -use number_property_type::NumberPropertyType; -use boolean_property_type::BooleanPropertyType; -use map_property_type::MapPropertyType; -use array_property_type::ArrayPropertyType; use any_property_type::AnyPropertyType; +use array_property_type::ArrayPropertyType; +use boolean_property_type::BooleanPropertyType; use generic_property_type::GenericPropertyType; +use integer_property_type::IntegerPropertyType; +use map_property_type::MapPropertyType; +use number_property_type::NumberPropertyType; use reference_property_type::ReferencePropertyType; +use string_property_type::StringPropertyType; // Base property type #[derive(Serialize, Deserialize)] pub struct PropertyType { - #[serde(rename = "description")] - description: Option<String>, - - #[serde(rename = "type")] - _type: Option<String>, - #[serde(rename = "deprecated")] deprecated: Option<bool>, + #[serde(rename = "description")] + description: Option<String>, + #[serde(rename = "nullable")] nullable: Option<bool>, + #[serde(rename = "type")] + _type: Option<String>, + } diff --git a/tests/Generator/resource/rust/complex/reference_property_type.rs b/tests/Generator/resource/rust/complex/reference_property_type.rs index 1cb09c8..50e356b 100644 --- a/tests/Generator/resource/rust/complex/reference_property_type.rs +++ b/tests/Generator/resource/rust/complex/reference_property_type.rs @@ -4,18 +4,18 @@ use property_type::PropertyType; // Represents a reference to a definition type #[derive(Serialize, Deserialize)] pub struct ReferencePropertyType { - #[serde(rename = "description")] - description: Option<String>, - - #[serde(rename = "type")] - _type: Option<String>, - #[serde(rename = "deprecated")] deprecated: Option<bool>, + #[serde(rename = "description")] + description: Option<String>, + #[serde(rename = "nullable")] nullable: Option<bool>, + #[serde(rename = "type")] + _type: Option<String>, + #[serde(rename = "target")] target: Option<String>, diff --git a/tests/Generator/resource/rust/complex/scalar_property_type.rs b/tests/Generator/resource/rust/complex/scalar_property_type.rs index 30551d7..0d89c5c 100644 --- a/tests/Generator/resource/rust/complex/scalar_property_type.rs +++ b/tests/Generator/resource/rust/complex/scalar_property_type.rs @@ -1,24 +1,24 @@ use serde::{Serialize, Deserialize}; -use string_property_type::StringPropertyType; +use boolean_property_type::BooleanPropertyType; use integer_property_type::IntegerPropertyType; use number_property_type::NumberPropertyType; -use boolean_property_type::BooleanPropertyType; +use string_property_type::StringPropertyType; use property_type::PropertyType; // Base scalar property type #[derive(Serialize, Deserialize)] pub struct ScalarPropertyType { - #[serde(rename = "description")] - description: Option<String>, - - #[serde(rename = "type")] - _type: Option<String>, - #[serde(rename = "deprecated")] deprecated: Option<bool>, + #[serde(rename = "description")] + description: Option<String>, + #[serde(rename = "nullable")] nullable: Option<bool>, + #[serde(rename = "type")] + _type: Option<String>, + } diff --git a/tests/Generator/resource/rust/complex/string_property_type.rs b/tests/Generator/resource/rust/complex/string_property_type.rs index 45ca41e..532005c 100644 --- a/tests/Generator/resource/rust/complex/string_property_type.rs +++ b/tests/Generator/resource/rust/complex/string_property_type.rs @@ -4,18 +4,18 @@ use scalar_property_type::ScalarPropertyType; // Represents a string value #[derive(Serialize, Deserialize)] pub struct StringPropertyType { - #[serde(rename = "description")] - description: Option<String>, - - #[serde(rename = "type")] - _type: Option<String>, - #[serde(rename = "deprecated")] deprecated: Option<bool>, + #[serde(rename = "description")] + description: Option<String>, + #[serde(rename = "nullable")] nullable: Option<bool>, + #[serde(rename = "type")] + _type: Option<String>, + #[serde(rename = "format")] format: Option<String>, diff --git a/tests/Generator/resource/rust/complex/struct_definition_type.rs b/tests/Generator/resource/rust/complex/struct_definition_type.rs index 6123889..53b52a8 100644 --- a/tests/Generator/resource/rust/complex/struct_definition_type.rs +++ b/tests/Generator/resource/rust/complex/struct_definition_type.rs @@ -6,29 +6,29 @@ use property_type::PropertyType; // A struct represents a class/structure with a fix set of defined properties. #[derive(Serialize, Deserialize)] pub struct StructDefinitionType { + #[serde(rename = "deprecated")] + deprecated: Option<bool>, + #[serde(rename = "description")] description: Option<String>, #[serde(rename = "type")] _type: Option<String>, - #[serde(rename = "deprecated")] - deprecated: Option<bool>, - - #[serde(rename = "parent")] - parent: Option<ReferencePropertyType>, - #[serde(rename = "base")] base: Option<bool>, - #[serde(rename = "properties")] - properties: Option<std::collections::HashMap<String, PropertyType>>, - #[serde(rename = "discriminator")] discriminator: Option<String>, #[serde(rename = "mapping")] mapping: Option<std::collections::HashMap<String, String>>, + #[serde(rename = "parent")] + parent: Option<ReferencePropertyType>, + + #[serde(rename = "properties")] + properties: Option<std::collections::HashMap<String, PropertyType>>, + } diff --git a/tests/Generator/resource/rust/complex/type_schema.rs b/tests/Generator/resource/rust/complex/type_schema.rs index e702283..c8a391e 100644 --- a/tests/Generator/resource/rust/complex/type_schema.rs +++ b/tests/Generator/resource/rust/complex/type_schema.rs @@ -4,12 +4,12 @@ use definition_type::DefinitionType; // TypeSchema specification #[derive(Serialize, Deserialize)] pub struct TypeSchema { - #[serde(rename = "import")] - import: Option<std::collections::HashMap<String, String>>, - #[serde(rename = "definitions")] definitions: Option<std::collections::HashMap<String, DefinitionType>>, + #[serde(rename = "import")] + import: Option<std::collections::HashMap<String, String>>, + #[serde(rename = "root")] root: Option<String>, diff --git a/tests/Generator/resource/source_typeschema.json b/tests/Generator/resource/source_typeschema.json index 0701177..60e1ee0 100644 --- a/tests/Generator/resource/source_typeschema.json +++ b/tests/Generator/resource/source_typeschema.json @@ -1,205 +1,85 @@ { "definitions": { - "Security": { - "description": "", + "AnyPropertyType": { + "description": "Represents an any value which allows any kind of value", "type": "struct", - "base": true, - "properties": { - "type": { - "description": "The global security type of the API must be one of: httpBasic, httpBearer, apiKey or oauth2", - "type": "string" - } - }, - "discriminator": "type", - "mapping": { - "SecurityHttpBasic": "httpBasic", - "SecurityHttpBearer": "httpBearer", - "SecurityApiKey": "apiKey", - "SecurityOAuth": "oauth2" + "parent": { + "type": "reference", + "target": "PropertyType" } }, - "SecurityHttpBasic": { + "ArrayDefinitionType": { + "description": "Represents an array which contains a dynamic list of values of the same type", "type": "struct", "parent": { "type": "reference", - "target": "Security" + "target": "CollectionDefinitionType" } }, - "SecurityHttpBearer": { + "ArrayPropertyType": { + "description": "Represents an array which contains a dynamic list of values of the same type", "type": "struct", "parent": { "type": "reference", - "target": "Security" + "target": "CollectionPropertyType" } }, - "SecurityApiKey": { + "BooleanPropertyType": { + "description": "Represents a boolean value", "type": "struct", "parent": { "type": "reference", - "target": "Security" - }, - "properties": { - "name": { - "description": "The name of the header or query parameter i.e. \"X-Api-Key\"", - "type": "string" - }, - "in": { - "description": "Must be either \"header\" or \"query\"", - "type": "string" - } + "target": "ScalarPropertyType" } }, - "SecurityOAuth": { + "CollectionDefinitionType": { + "description": "Base collection type", "type": "struct", "parent": { "type": "reference", - "target": "Security" + "target": "DefinitionType" }, + "base": true, "properties": { - "tokenUrl": { - "description": "The OAuth2 token endpoint", - "type": "string" - }, - "authorizationUrl": { - "description": "Optional the OAuth2 authorization endpoint", - "type": "string" - }, - "scopes": { - "description": "Optional OAuth2 scopes", - "type": "array", - "items": { - "type": "string" - } - } - } - }, - "Operation": { - "description": "", - "type": "struct", - "properties": { - "method": { - "description": "The HTTP method which is associated with this operation, must be a valid HTTP method i.e. GET, POST, PUT etc.", - "type": "string" - }, - "path": { - "description": "The HTTP path which is associated with this operation. A path can also include variable path fragments i.e. /my/path/:year then you can map the variable year path fragment to a specific argument", - "type": "string" - }, - "return": { - "description": "The return type of this operation. The return has also an assigned HTTP success status code which is by default 200", - "$ref": "Response" - }, - "arguments": { - "description": "All arguments provided to this operation. Each argument is mapped to a location from the HTTP request i.e. query or body", - "type": "map", - "schema": { - "type": "reference", - "target": "Argument" - } - }, - "throws": { - "description": "All exceptional states which can occur in case the operation fails. Each exception is assigned to an HTTP error status code", - "type": "array", - "schema": { - "type": "reference", - "target": "Response" - } - }, - "description": { - "description": "A short description of this operation. The generated code will include this description at the method so it is recommend to use simple alphanumeric characters and no new lines", - "type": "string" - }, - "stability": { - "description": "Indicates the stability of this operation: 0 - Deprecated, 1 - Experimental, 2 - Stable, 3 - Legacy. If not explicit provided the operation is by default experimental.", - "type": "integer" - }, - "security": { - "description": "An array of scopes which are required to access this operation", - "type": "array", - "schema": { - "type": "string" - } - }, - "authorization": { - "description": "Indicates whether this operation needs authorization, if set to false the client will not send an authorization header, default it is true", - "type": "boolean" - }, - "tags": { - "description": "Optional an array of tags to group operations", - "type": "array", - "schema": { - "type": "string" - } - } - } - }, - "Argument": { - "description": "", - "type": "struct", - "properties": { - "in": { - "description": "The location where the value can be found either in the path, query, header or body. If you choose path, then your path must have a fitting variable path fragment", - "type": "string" - }, "schema": { "description": "", "type": "reference", "target": "PropertyType" }, - "contentType": { - "description": "In case the data is not a JSON payload which you can describe with a schema you can select a content type", - "type": "string" - }, - "name": { - "description": "Optional the actual path, query or header name. If not provided the key of the argument map is used", - "type": "string" - } - } - }, - "Response": { - "description": "", - "type": "struct", - "properties": { - "code": { - "description": "The associated HTTP response code. For error responses it is possible to use the 499, 599 or 999 status code to catch all errors", - "type": "integer" - }, - "contentType": { - "description": "In case the data is not a JSON payload which you can describe with a schema you can select a content type", - "type": "string" - }, - "schema": { + "type": { "description": "", - "type": "reference", - "target": "PropertyType" + "type": "string" } + }, + "discriminator": "type", + "mapping": { + "ArrayDefinitionType": "array", + "MapDefinitionType": "map" } }, - "TypeAPI": { - "description": "The TypeAPI Root", + "CollectionPropertyType": { + "description": "Base collection property type", "type": "struct", "parent": { "type": "reference", - "target": "TypeSchema" + "target": "PropertyType" }, + "base": true, "properties": { - "baseUrl": { - "description": "Optional the base url of the service, if provided the user does not need to provide a base url for your client", - "type": "string" - }, - "security": { - "description": "Describes the authorization mechanism which is used by your API", + "schema": { + "description": "", "type": "reference", - "target": "Security" + "target": "PropertyType" }, - "operations": { - "description": "A map of operations which are provided by the API. The key of the operation should be separated by a dot to group operations into logical units i.e. product.getAll or enterprise.product.execute", - "type": "map", - "schema": { - "type": "reference", - "target": "Operation" - } + "type": { + "description": "", + "type": "string" } + }, + "discriminator": "type", + "mapping": { + "ArrayPropertyType": "array", + "MapPropertyType": "map" } }, "DefinitionType": { @@ -207,80 +87,46 @@ "type": "struct", "base": true, "properties": { + "deprecated": { + "description": "", + "type": "boolean" + }, "description": { + "description": "", "type": "string" }, "type": { + "description": "", "type": "string" - }, - "deprecated": { - "type": "boolean" } }, "discriminator": "type", "mapping": { - "StructDefinitionType": "struct", + "ArrayDefinitionType": "array", "MapDefinitionType": "map", - "ArrayDefinitionType": "array" + "StructDefinitionType": "struct" } }, - "StructDefinitionType": { - "description": "A struct represents a class/structure with a fix set of defined properties.", + "GenericPropertyType": { + "description": "Represents a generic value which can be replaced with a dynamic type", "type": "struct", "parent": { "type": "reference", - "target": "DefinitionType" + "target": "PropertyType" }, "properties": { - "parent": { - "description": "Defines a parent type for this structure. Some programming languages like Go do not support the concept of an extends, in this case the code generator simply copies all properties into this structure.", - "type": "reference", - "target": "ReferencePropertyType" - }, - "base": { - "description": "Indicates whether this is a base structure, default is false. If true the structure is used a base type, this means it is not possible to create an instance from this structure.", - "type": "boolean" - }, - "properties": { - "description": "Contains a map of available properties for this struct.", - "type": "map", - "schema": { - "type": "reference", - "target": "PropertyType" - } - }, - "discriminator": { - "description": "Optional the property name of a discriminator property. This should be only used in case this is also a base structure.", + "name": { + "description": "The name of the generic, it is recommended to use common generic names like T or TValue. These generics can then be replaced on usage with a concrete type through the template property at a reference.", "type": "string" - }, - "mapping": { - "description": "In case a discriminator is configured it is required to configure a mapping. The mapping is a map where the key is the type name and the value the actual discriminator type value.", - "type": "map", - "schema": { - "type": "string" - } } } }, - "CollectionDefinitionType": { - "description": "Base collection type", + "IntegerPropertyType": { + "description": "Represents an integer value", "type": "struct", "parent": { "type": "reference", - "target": "DefinitionType" - }, - "base": true, - "properties": { - "schema": { - "description": "", - "type": "reference", - "target": "PropertyType" - } - }, - "discriminator": "type", - "mapping": { - "MapDefinitionType": "map", - "ArrayDefinitionType": "array" + "target": "ScalarPropertyType" } }, "MapDefinitionType": { @@ -291,12 +137,20 @@ "target": "CollectionDefinitionType" } }, - "ArrayDefinitionType": { - "description": "Represents an array which contains a dynamic list of values of the same type", + "MapPropertyType": { + "description": "Represents a map which contains a dynamic set of key value entries of the same type", "type": "struct", "parent": { "type": "reference", - "target": "CollectionDefinitionType" + "target": "CollectionPropertyType" + } + }, + "NumberPropertyType": { + "description": "Represents a float value", + "type": "struct", + "parent": { + "type": "reference", + "target": "ScalarPropertyType" } }, "PropertyType": { @@ -304,88 +158,59 @@ "type": "struct", "base": true, "properties": { - "description": { - "type": "string" - }, - "type": { - "type": "string" - }, "deprecated": { + "description": "", "type": "boolean" }, + "description": { + "description": "", + "type": "string" + }, "nullable": { + "description": "", "type": "boolean" + }, + "type": { + "description": "", + "type": "string" } }, "discriminator": "type", "mapping": { - "StringPropertyType": "string", - "IntegerPropertyType": "integer", - "NumberPropertyType": "number", - "BooleanPropertyType": "boolean", - "MapPropertyType": "map", - "ArrayPropertyType": "array", "AnyPropertyType": "any", + "ArrayPropertyType": "array", + "BooleanPropertyType": "boolean", "GenericPropertyType": "generic", - "ReferencePropertyType": "reference" - } - }, - "ScalarPropertyType": { - "description": "Base scalar property type", - "type": "struct", - "parent": { - "type": "reference", - "target": "PropertyType" - }, - "base": true, - "discriminator": "type", - "mapping": { - "StringPropertyType": "string", "IntegerPropertyType": "integer", + "MapPropertyType": "map", "NumberPropertyType": "number", - "BooleanPropertyType": "boolean" + "ReferencePropertyType": "reference", + "StringPropertyType": "string" } }, - "StringPropertyType": { - "description": "Represents a string value", + "ReferencePropertyType": { + "description": "Represents a reference to a definition type", "type": "struct", "parent": { "type": "reference", - "target": "ScalarPropertyType" + "target": "PropertyType" }, "properties": { - "format": { - "description": "Optional describes the format of the string. Supported are the following types: date, date-time and time. A code generator may use a fitting data type to represent such a format, if not supported it should fall back to a string.", + "target": { + "description": "The target type, this must be a key which is available under the definitions keyword.", "type": "string" + }, + "template": { + "description": "A map where the key is the name of the generic and the value must point to a key under the definitions keyword. This can be used in case the target points to a type which contains generics, then it is possible to replace those generics with a concrete type.", + "type": "map", + "schema": { + "type": "string" + } } } }, - "IntegerPropertyType": { - "description": "Represents an integer value", - "type": "struct", - "parent": { - "type": "reference", - "target": "ScalarPropertyType" - } - }, - "NumberPropertyType": { - "description": "Represents a float value", - "type": "struct", - "parent": { - "type": "reference", - "target": "ScalarPropertyType" - } - }, - "BooleanPropertyType": { - "description": "Represents a boolean value", - "type": "struct", - "parent": { - "type": "reference", - "target": "ScalarPropertyType" - } - }, - "CollectionPropertyType": { - "description": "Base collection property type", + "ScalarPropertyType": { + "description": "Base scalar property type", "type": "struct", "parent": { "type": "reference", @@ -393,69 +218,68 @@ }, "base": true, "properties": { - "schema": { + "type": { "description": "", - "type": "reference", - "target": "PropertyType" + "type": "string" } + }, + "discriminator": "type", + "mapping": { + "BooleanPropertyType": "boolean", + "IntegerPropertyType": "integer", + "NumberPropertyType": "number", + "StringPropertyType": "string" } }, - "MapPropertyType": { - "description": "Represents a map which contains a dynamic set of key value entries of the same type", - "type": "struct", - "parent": { - "type": "reference", - "target": "CollectionPropertyType" - } - }, - "ArrayPropertyType": { - "description": "Represents an array which contains a dynamic list of values of the same type", - "type": "struct", - "parent": { - "type": "reference", - "target": "CollectionPropertyType" - } - }, - "AnyPropertyType": { - "description": "Represents an any value which allows any kind of value", - "type": "struct", - "parent": { - "type": "reference", - "target": "PropertyType" - } - }, - "GenericPropertyType": { - "description": "Represents a generic value which can be replaced with a dynamic type", + "StringPropertyType": { + "description": "Represents a string value", "type": "struct", "parent": { "type": "reference", - "target": "PropertyType" + "target": "ScalarPropertyType" }, "properties": { - "name": { - "description": "The name of the generic, it is recommended to use common generic names like T or TValue. These generics can then be replaced on usage with a concrete type through the template property at a reference.", + "format": { + "description": "Optional describes the format of the string. Supported are the following types: date, date-time and time. A code generator may use a fitting data type to represent such a format, if not supported it should fall back to a string.", "type": "string" } } }, - "ReferencePropertyType": { - "description": "Represents a reference to a definition type", + "StructDefinitionType": { + "description": "A struct represents a class/structure with a fix set of defined properties.", "type": "struct", "parent": { "type": "reference", - "target": "PropertyType" + "target": "DefinitionType" }, "properties": { - "target": { - "description": "The target type, this must be a key which is available under the definitions keyword.", + "base": { + "description": "Indicates whether this is a base structure, default is false. If true the structure is used a base type, this means it is not possible to create an instance from this structure.", + "type": "boolean" + }, + "discriminator": { + "description": "Optional the property name of a discriminator property. This should be only used in case this is also a base structure.", "type": "string" }, - "template": { - "description": "A map where the key is the name of the generic and the value must point to a key under the definitions keyword. This can be used in case the target points to a type which contains generics, then it is possible to replace those generics with a concrete type.", + "mapping": { + "description": "In case a discriminator is configured it is required to configure a mapping. The mapping is a map where the key is the type name and the value the actual discriminator type value.", "type": "map", "schema": { "type": "string" } + }, + "parent": { + "description": "Defines a parent type for this structure. Some programming languages like Go do not support the concept of an extends, in this case the code generator simply copies all properties into this structure.", + "type": "reference", + "target": "ReferencePropertyType" + }, + "properties": { + "description": "Contains a map of available properties for this struct.", + "type": "map", + "schema": { + "type": "reference", + "target": "PropertyType" + } } } }, @@ -463,18 +287,19 @@ "description": "TypeSchema specification", "type": "struct", "properties": { - "import": { - "description": "Through the import keyword it is possible to import other TypeSchema documents. It contains a map where the key is the namespace and the value points to a remote document. The value is a URL and a code generator should support at least the following schemes: file, http, https.", + "definitions": { + "description": "", "type": "map", "schema": { - "type": "string" + "type": "reference", + "target": "DefinitionType" } }, - "definitions": { + "import": { + "description": "Through the import keyword it is possible to import other TypeSchema documents. It contains a map where the key is the namespace and the value points to a remote document. The value is a URL and a code generator should support at least the following schemes: file, http, https.", "type": "map", "schema": { - "type": "reference", - "target": "DefinitionType" + "type": "string" } }, "root": { @@ -483,6 +308,5 @@ } } } - }, - "root": "TypeAPI" -} + } +} \ No newline at end of file diff --git a/tests/Generator/resource/swift/complex/CollectionDefinitionType.swift b/tests/Generator/resource/swift/complex/CollectionDefinitionType.swift index 751337b..0bd0248 100644 --- a/tests/Generator/resource/swift/complex/CollectionDefinitionType.swift +++ b/tests/Generator/resource/swift/complex/CollectionDefinitionType.swift @@ -1,9 +1,11 @@ // Base collection type class CollectionDefinitionType: DefinitionType { var schema: PropertyType + var _type: String enum CodingKeys: String, CodingKey { case schema = "schema" + case _type = "type" } } diff --git a/tests/Generator/resource/swift/complex/CollectionPropertyType.swift b/tests/Generator/resource/swift/complex/CollectionPropertyType.swift index fe47923..a11946b 100644 --- a/tests/Generator/resource/swift/complex/CollectionPropertyType.swift +++ b/tests/Generator/resource/swift/complex/CollectionPropertyType.swift @@ -1,9 +1,11 @@ // Base collection property type class CollectionPropertyType: PropertyType { var schema: PropertyType + var _type: String enum CodingKeys: String, CodingKey { case schema = "schema" + case _type = "type" } } diff --git a/tests/Generator/resource/swift/complex/DefinitionType.swift b/tests/Generator/resource/swift/complex/DefinitionType.swift index 49ed9bb..b9dbf45 100644 --- a/tests/Generator/resource/swift/complex/DefinitionType.swift +++ b/tests/Generator/resource/swift/complex/DefinitionType.swift @@ -1,13 +1,13 @@ // Base definition type class DefinitionType: Codable { + var deprecated: Bool var description: String var _type: String - var deprecated: Bool enum CodingKeys: String, CodingKey { + case deprecated = "deprecated" case description = "description" case _type = "type" - case deprecated = "deprecated" } } diff --git a/tests/Generator/resource/swift/complex/PropertyType.swift b/tests/Generator/resource/swift/complex/PropertyType.swift index a5730b9..306d8a7 100644 --- a/tests/Generator/resource/swift/complex/PropertyType.swift +++ b/tests/Generator/resource/swift/complex/PropertyType.swift @@ -1,15 +1,15 @@ // Base property type class PropertyType: Codable { - var description: String - var _type: String var deprecated: Bool + var description: String var nullable: Bool + var _type: String enum CodingKeys: String, CodingKey { - case description = "description" - case _type = "type" case deprecated = "deprecated" + case description = "description" case nullable = "nullable" + case _type = "type" } } diff --git a/tests/Generator/resource/swift/complex/ScalarPropertyType.swift b/tests/Generator/resource/swift/complex/ScalarPropertyType.swift index e59b0b0..1748efd 100644 --- a/tests/Generator/resource/swift/complex/ScalarPropertyType.swift +++ b/tests/Generator/resource/swift/complex/ScalarPropertyType.swift @@ -1,7 +1,9 @@ // Base scalar property type class ScalarPropertyType: PropertyType { + var _type: String enum CodingKeys: String, CodingKey { + case _type = "type" } } diff --git a/tests/Generator/resource/swift/complex/StructDefinitionType.swift b/tests/Generator/resource/swift/complex/StructDefinitionType.swift index 2a283a4..e705ee8 100644 --- a/tests/Generator/resource/swift/complex/StructDefinitionType.swift +++ b/tests/Generator/resource/swift/complex/StructDefinitionType.swift @@ -1,17 +1,17 @@ // A struct represents a class/structure with a fix set of defined properties. class StructDefinitionType: DefinitionType { - var parent: ReferencePropertyType var base: Bool - var properties: Dictionary<String, PropertyType> var discriminator: String var mapping: Dictionary<String, String> + var parent: ReferencePropertyType + var properties: Dictionary<String, PropertyType> enum CodingKeys: String, CodingKey { - case parent = "parent" case base = "base" - case properties = "properties" case discriminator = "discriminator" case mapping = "mapping" + case parent = "parent" + case properties = "properties" } } diff --git a/tests/Generator/resource/swift/complex/TypeSchema.swift b/tests/Generator/resource/swift/complex/TypeSchema.swift index 5b4e7e3..acd578b 100644 --- a/tests/Generator/resource/swift/complex/TypeSchema.swift +++ b/tests/Generator/resource/swift/complex/TypeSchema.swift @@ -1,12 +1,12 @@ // TypeSchema specification class TypeSchema: Codable { - var _import: Dictionary<String, String> var definitions: Dictionary<String, DefinitionType> + var _import: Dictionary<String, String> var root: String enum CodingKeys: String, CodingKey { - case _import = "import" case definitions = "definitions" + case _import = "import" case root = "root" } } diff --git a/tests/Generator/resource/typeschema/typeschema_complex.json b/tests/Generator/resource/typeschema/typeschema_complex.json index 196da10..cb9ae68 100644 --- a/tests/Generator/resource/typeschema/typeschema_complex.json +++ b/tests/Generator/resource/typeschema/typeschema_complex.json @@ -8,29 +8,6 @@ "target": "PropertyType" } }, - "Argument": { - "description": "", - "type": "struct", - "properties": { - "in": { - "description": "The location where the value can be found either in the path, query, header or body. If you choose path, then your path must have a fitting variable path fragment", - "type": "string" - }, - "schema": { - "description": "", - "type": "reference", - "target": "PropertyType" - }, - "contentType": { - "description": "In case the data is not a JSON payload which you can describe with a schema you can select a content type", - "type": "string" - }, - "name": { - "description": "Optional the actual path, query or header name. If not provided the key of the argument map is used", - "type": "string" - } - } - }, "ArrayDefinitionType": { "description": "Represents an array which contains a dynamic list of values of the same type", "type": "struct", @@ -68,12 +45,16 @@ "description": "", "type": "reference", "target": "PropertyType" + }, + "type": { + "description": "", + "type": "string" } }, "discriminator": "type", "mapping": { - "MapDefinitionType": "map", - "ArrayDefinitionType": "array" + "ArrayDefinitionType": "array", + "MapDefinitionType": "map" } }, "CollectionPropertyType": { @@ -89,7 +70,16 @@ "description": "", "type": "reference", "target": "PropertyType" + }, + "type": { + "description": "", + "type": "string" } + }, + "discriminator": "type", + "mapping": { + "ArrayPropertyType": "array", + "MapPropertyType": "map" } }, "DefinitionType": { @@ -97,21 +87,24 @@ "type": "struct", "base": true, "properties": { + "deprecated": { + "description": "", + "type": "boolean" + }, "description": { + "description": "", "type": "string" }, "type": { + "description": "", "type": "string" - }, - "deprecated": { - "type": "boolean" } }, "discriminator": "type", "mapping": { - "StructDefinitionType": "struct", + "ArrayDefinitionType": "array", "MapDefinitionType": "map", - "ArrayDefinitionType": "array" + "StructDefinitionType": "struct" } }, "GenericPropertyType": { @@ -160,96 +153,39 @@ "target": "ScalarPropertyType" } }, - "Operation": { - "description": "", - "type": "struct", - "properties": { - "method": { - "description": "The HTTP method which is associated with this operation, must be a valid HTTP method i.e. GET, POST, PUT etc.", - "type": "string" - }, - "path": { - "description": "The HTTP path which is associated with this operation. A path can also include variable path fragments i.e. /my/path/:year then you can map the variable year path fragment to a specific argument", - "type": "string" - }, - "return": { - "description": "The return type of this operation. The return has also an assigned HTTP success status code which is by default 200", - "type": "reference", - "target": "Response" - }, - "arguments": { - "description": "All arguments provided to this operation. Each argument is mapped to a location from the HTTP request i.e. query or body", - "type": "map", - "schema": { - "type": "reference", - "target": "Argument" - } - }, - "throws": { - "description": "All exceptional states which can occur in case the operation fails. Each exception is assigned to an HTTP error status code", - "type": "array", - "schema": { - "type": "reference", - "target": "Response" - } - }, - "description": { - "description": "A short description of this operation. The generated code will include this description at the method so it is recommend to use simple alphanumeric characters and no new lines", - "type": "string" - }, - "stability": { - "description": "Indicates the stability of this operation: 0 - Deprecated, 1 - Experimental, 2 - Stable, 3 - Legacy. If not explicit provided the operation is by default experimental.", - "type": "integer" - }, - "security": { - "description": "An array of scopes which are required to access this operation", - "type": "array", - "schema": { - "type": "string" - } - }, - "authorization": { - "description": "Indicates whether this operation needs authorization, if set to false the client will not send an authorization header, default it is true", - "type": "boolean" - }, - "tags": { - "description": "Optional an array of tags to group operations", - "type": "array", - "schema": { - "type": "string" - } - } - } - }, "PropertyType": { "description": "Base property type", "type": "struct", "base": true, "properties": { - "description": { - "type": "string" - }, - "type": { - "type": "string" - }, "deprecated": { + "description": "", "type": "boolean" }, + "description": { + "description": "", + "type": "string" + }, "nullable": { + "description": "", "type": "boolean" + }, + "type": { + "description": "", + "type": "string" } }, "discriminator": "type", "mapping": { - "StringPropertyType": "string", - "IntegerPropertyType": "integer", - "NumberPropertyType": "number", - "BooleanPropertyType": "boolean", - "MapPropertyType": "map", - "ArrayPropertyType": "array", "AnyPropertyType": "any", + "ArrayPropertyType": "array", + "BooleanPropertyType": "boolean", "GenericPropertyType": "generic", - "ReferencePropertyType": "reference" + "IntegerPropertyType": "integer", + "MapPropertyType": "map", + "NumberPropertyType": "number", + "ReferencePropertyType": "reference", + "StringPropertyType": "string" } }, "ReferencePropertyType": { @@ -273,25 +209,6 @@ } } }, - "Response": { - "description": "", - "type": "struct", - "properties": { - "code": { - "description": "The associated HTTP response code. For error responses it is possible to use the 499, 599 or 999 status code to catch all errors", - "type": "integer" - }, - "contentType": { - "description": "In case the data is not a JSON payload which you can describe with a schema you can select a content type", - "type": "string" - }, - "schema": { - "description": "", - "type": "reference", - "target": "PropertyType" - } - } - }, "ScalarPropertyType": { "description": "Base scalar property type", "type": "struct", @@ -300,85 +217,18 @@ "target": "PropertyType" }, "base": true, - "discriminator": "type", - "mapping": { - "StringPropertyType": "string", - "IntegerPropertyType": "integer", - "NumberPropertyType": "number", - "BooleanPropertyType": "boolean" - } - }, - "Security": { - "description": "", - "type": "struct", - "base": true, "properties": { "type": { - "description": "The global security type of the API must be one of: httpBasic, httpBearer, apiKey or oauth2", + "description": "", "type": "string" } }, "discriminator": "type", "mapping": { - "SecurityHttpBasic": "httpBasic", - "SecurityHttpBearer": "httpBearer", - "SecurityApiKey": "apiKey", - "SecurityOAuth": "oauth2" - } - }, - "SecurityApiKey": { - "type": "struct", - "parent": { - "type": "reference", - "target": "Security" - }, - "properties": { - "name": { - "description": "The name of the header or query parameter i.e. \"X-Api-Key\"", - "type": "string" - }, - "in": { - "description": "Must be either \"header\" or \"query\"", - "type": "string" - } - } - }, - "SecurityHttpBasic": { - "type": "struct", - "parent": { - "type": "reference", - "target": "Security" - } - }, - "SecurityHttpBearer": { - "type": "struct", - "parent": { - "type": "reference", - "target": "Security" - } - }, - "SecurityOAuth": { - "type": "struct", - "parent": { - "type": "reference", - "target": "Security" - }, - "properties": { - "tokenUrl": { - "description": "The OAuth2 token endpoint", - "type": "string" - }, - "authorizationUrl": { - "description": "Optional the OAuth2 authorization endpoint", - "type": "string" - }, - "scopes": { - "description": "Optional OAuth2 scopes", - "type": "array", - "schema": { - "type": "string" - } - } + "BooleanPropertyType": "boolean", + "IntegerPropertyType": "integer", + "NumberPropertyType": "number", + "StringPropertyType": "string" } }, "StringPropertyType": { @@ -403,23 +253,10 @@ "target": "DefinitionType" }, "properties": { - "parent": { - "description": "Defines a parent type for this structure. Some programming languages like Go do not support the concept of an extends, in this case the code generator simply copies all properties into this structure.", - "type": "reference", - "target": "ReferencePropertyType" - }, "base": { "description": "Indicates whether this is a base structure, default is false. If true the structure is used a base type, this means it is not possible to create an instance from this structure.", "type": "boolean" }, - "properties": { - "description": "Contains a map of available properties for this struct.", - "type": "map", - "schema": { - "type": "reference", - "target": "PropertyType" - } - }, "discriminator": { "description": "Optional the property name of a discriminator property. This should be only used in case this is also a base structure.", "type": "string" @@ -430,32 +267,18 @@ "schema": { "type": "string" } - } - } - }, - "TypeAPI": { - "description": "The TypeAPI Root", - "type": "struct", - "parent": { - "type": "reference", - "target": "TypeSchema" - }, - "properties": { - "baseUrl": { - "description": "Optional the base url of the service, if provided the user does not need to provide a base url for your client", - "type": "string" }, - "security": { - "description": "Describes the authorization mechanism which is used by your API", + "parent": { + "description": "Defines a parent type for this structure. Some programming languages like Go do not support the concept of an extends, in this case the code generator simply copies all properties into this structure.", "type": "reference", - "target": "Security" + "target": "ReferencePropertyType" }, - "operations": { - "description": "A map of operations which are provided by the API. The key of the operation should be separated by a dot to group operations into logical units i.e. product.getAll or enterprise.product.execute", + "properties": { + "description": "Contains a map of available properties for this struct.", "type": "map", "schema": { "type": "reference", - "target": "Operation" + "target": "PropertyType" } } } @@ -464,18 +287,19 @@ "description": "TypeSchema specification", "type": "struct", "properties": { - "import": { - "description": "Through the import keyword it is possible to import other TypeSchema documents. It contains a map where the key is the namespace and the value points to a remote document. The value is a URL and a code generator should support at least the following schemes: file, http, https.", + "definitions": { + "description": "", "type": "map", "schema": { - "type": "string" + "type": "reference", + "target": "DefinitionType" } }, - "definitions": { + "import": { + "description": "Through the import keyword it is possible to import other TypeSchema documents. It contains a map where the key is the namespace and the value points to a remote document. The value is a URL and a code generator should support at least the following schemes: file, http, https.", "type": "map", "schema": { - "type": "reference", - "target": "DefinitionType" + "type": "string" } }, "root": { @@ -484,6 +308,5 @@ } } } - }, - "root": "TypeAPI" -} + } +} \ No newline at end of file diff --git a/tests/Generator/resource/typescript/complex/CollectionDefinitionType.ts b/tests/Generator/resource/typescript/complex/CollectionDefinitionType.ts index bac8f3d..722bd25 100644 --- a/tests/Generator/resource/typescript/complex/CollectionDefinitionType.ts +++ b/tests/Generator/resource/typescript/complex/CollectionDefinitionType.ts @@ -1,5 +1,5 @@ -import {MapDefinitionType} from "./MapDefinitionType"; import {ArrayDefinitionType} from "./ArrayDefinitionType"; +import {MapDefinitionType} from "./MapDefinitionType"; import {DefinitionType} from "./DefinitionType"; import {PropertyType} from "./PropertyType"; @@ -8,5 +8,6 @@ import {PropertyType} from "./PropertyType"; */ export interface CollectionDefinitionType extends DefinitionType { schema?: PropertyType + type?: string } diff --git a/tests/Generator/resource/typescript/complex/CollectionPropertyType.ts b/tests/Generator/resource/typescript/complex/CollectionPropertyType.ts index 2860181..9263df2 100644 --- a/tests/Generator/resource/typescript/complex/CollectionPropertyType.ts +++ b/tests/Generator/resource/typescript/complex/CollectionPropertyType.ts @@ -1,3 +1,5 @@ +import {ArrayPropertyType} from "./ArrayPropertyType"; +import {MapPropertyType} from "./MapPropertyType"; import {PropertyType} from "./PropertyType"; /** @@ -5,5 +7,6 @@ import {PropertyType} from "./PropertyType"; */ export interface CollectionPropertyType extends PropertyType { schema?: PropertyType + type?: string } diff --git a/tests/Generator/resource/typescript/complex/DefinitionType.ts b/tests/Generator/resource/typescript/complex/DefinitionType.ts index 97cb320..e80191e 100644 --- a/tests/Generator/resource/typescript/complex/DefinitionType.ts +++ b/tests/Generator/resource/typescript/complex/DefinitionType.ts @@ -1,13 +1,13 @@ -import {StructDefinitionType} from "./StructDefinitionType"; -import {MapDefinitionType} from "./MapDefinitionType"; import {ArrayDefinitionType} from "./ArrayDefinitionType"; +import {MapDefinitionType} from "./MapDefinitionType"; +import {StructDefinitionType} from "./StructDefinitionType"; /** * Base definition type */ export interface DefinitionType { + deprecated?: boolean description?: string type?: string - deprecated?: boolean } diff --git a/tests/Generator/resource/typescript/complex/PropertyType.ts b/tests/Generator/resource/typescript/complex/PropertyType.ts index cfbc5bb..7b8efff 100644 --- a/tests/Generator/resource/typescript/complex/PropertyType.ts +++ b/tests/Generator/resource/typescript/complex/PropertyType.ts @@ -1,20 +1,20 @@ -import {StringPropertyType} from "./StringPropertyType"; -import {IntegerPropertyType} from "./IntegerPropertyType"; -import {NumberPropertyType} from "./NumberPropertyType"; -import {BooleanPropertyType} from "./BooleanPropertyType"; -import {MapPropertyType} from "./MapPropertyType"; -import {ArrayPropertyType} from "./ArrayPropertyType"; import {AnyPropertyType} from "./AnyPropertyType"; +import {ArrayPropertyType} from "./ArrayPropertyType"; +import {BooleanPropertyType} from "./BooleanPropertyType"; import {GenericPropertyType} from "./GenericPropertyType"; +import {IntegerPropertyType} from "./IntegerPropertyType"; +import {MapPropertyType} from "./MapPropertyType"; +import {NumberPropertyType} from "./NumberPropertyType"; import {ReferencePropertyType} from "./ReferencePropertyType"; +import {StringPropertyType} from "./StringPropertyType"; /** * Base property type */ export interface PropertyType { - description?: string - type?: string deprecated?: boolean + description?: string nullable?: boolean + type?: string } diff --git a/tests/Generator/resource/typescript/complex/ScalarPropertyType.ts b/tests/Generator/resource/typescript/complex/ScalarPropertyType.ts index 0667eae..71bcafe 100644 --- a/tests/Generator/resource/typescript/complex/ScalarPropertyType.ts +++ b/tests/Generator/resource/typescript/complex/ScalarPropertyType.ts @@ -1,12 +1,13 @@ -import {StringPropertyType} from "./StringPropertyType"; +import {BooleanPropertyType} from "./BooleanPropertyType"; import {IntegerPropertyType} from "./IntegerPropertyType"; import {NumberPropertyType} from "./NumberPropertyType"; -import {BooleanPropertyType} from "./BooleanPropertyType"; +import {StringPropertyType} from "./StringPropertyType"; import {PropertyType} from "./PropertyType"; /** * Base scalar property type */ export interface ScalarPropertyType extends PropertyType { + type?: string } diff --git a/tests/Generator/resource/typescript/complex/StructDefinitionType.ts b/tests/Generator/resource/typescript/complex/StructDefinitionType.ts index e32b464..a5f1b2f 100644 --- a/tests/Generator/resource/typescript/complex/StructDefinitionType.ts +++ b/tests/Generator/resource/typescript/complex/StructDefinitionType.ts @@ -6,10 +6,10 @@ import {PropertyType} from "./PropertyType"; * A struct represents a class/structure with a fix set of defined properties. */ export interface StructDefinitionType extends DefinitionType { - parent?: ReferencePropertyType base?: boolean - properties?: Map<string, PropertyType> discriminator?: string mapping?: Map<string, string> + parent?: ReferencePropertyType + properties?: Map<string, PropertyType> } diff --git a/tests/Generator/resource/typescript/complex/TypeSchema.ts b/tests/Generator/resource/typescript/complex/TypeSchema.ts index cb7d21c..fd952ad 100644 --- a/tests/Generator/resource/typescript/complex/TypeSchema.ts +++ b/tests/Generator/resource/typescript/complex/TypeSchema.ts @@ -4,8 +4,8 @@ import {DefinitionType} from "./DefinitionType"; * TypeSchema specification */ export interface TypeSchema { - import?: Map<string, string> definitions?: Map<string, DefinitionType> + import?: Map<string, string> root?: string } diff --git a/tests/Generator/resource/visualbasic/complex/CollectionDefinitionType.vb b/tests/Generator/resource/visualbasic/complex/CollectionDefinitionType.vb index ca78e90..77c1792 100644 --- a/tests/Generator/resource/visualbasic/complex/CollectionDefinitionType.vb +++ b/tests/Generator/resource/visualbasic/complex/CollectionDefinitionType.vb @@ -6,5 +6,8 @@ Public Class CollectionDefinitionType <JsonPropertyName("schema")> Public Property Schema As PropertyType + <JsonPropertyName("type")> + Public Property Type As String + End Class diff --git a/tests/Generator/resource/visualbasic/complex/CollectionPropertyType.vb b/tests/Generator/resource/visualbasic/complex/CollectionPropertyType.vb index 74c3d87..68ac78b 100644 --- a/tests/Generator/resource/visualbasic/complex/CollectionPropertyType.vb +++ b/tests/Generator/resource/visualbasic/complex/CollectionPropertyType.vb @@ -6,5 +6,8 @@ Public Class CollectionPropertyType <JsonPropertyName("schema")> Public Property Schema As PropertyType + <JsonPropertyName("type")> + Public Property Type As String + End Class diff --git a/tests/Generator/resource/visualbasic/complex/DefinitionType.vb b/tests/Generator/resource/visualbasic/complex/DefinitionType.vb index fabb3fc..ffb2870 100644 --- a/tests/Generator/resource/visualbasic/complex/DefinitionType.vb +++ b/tests/Generator/resource/visualbasic/complex/DefinitionType.vb @@ -2,14 +2,14 @@ Imports System.Text.Json.Serialization ' Base definition type Public Class DefinitionType + <JsonPropertyName("deprecated")> + Public Property Deprecated As Boolean + <JsonPropertyName("description")> Public Property Description As String <JsonPropertyName("type")> Public Property Type As String - <JsonPropertyName("deprecated")> - Public Property Deprecated As Boolean - End Class diff --git a/tests/Generator/resource/visualbasic/complex/PropertyType.vb b/tests/Generator/resource/visualbasic/complex/PropertyType.vb index c486c30..a7d7509 100644 --- a/tests/Generator/resource/visualbasic/complex/PropertyType.vb +++ b/tests/Generator/resource/visualbasic/complex/PropertyType.vb @@ -2,17 +2,17 @@ Imports System.Text.Json.Serialization ' Base property type Public Class PropertyType - <JsonPropertyName("description")> - Public Property Description As String - - <JsonPropertyName("type")> - Public Property Type As String - <JsonPropertyName("deprecated")> Public Property Deprecated As Boolean + <JsonPropertyName("description")> + Public Property Description As String + <JsonPropertyName("nullable")> Public Property Nullable As Boolean + <JsonPropertyName("type")> + Public Property Type As String + End Class diff --git a/tests/Generator/resource/visualbasic/complex/ScalarPropertyType.vb b/tests/Generator/resource/visualbasic/complex/ScalarPropertyType.vb index efc3e06..e8ae4ee 100644 --- a/tests/Generator/resource/visualbasic/complex/ScalarPropertyType.vb +++ b/tests/Generator/resource/visualbasic/complex/ScalarPropertyType.vb @@ -3,5 +3,8 @@ Imports System.Text.Json.Serialization ' Base scalar property type Public Class ScalarPropertyType Inherits PropertyType + <JsonPropertyName("type")> + Public Property Type As String + End Class diff --git a/tests/Generator/resource/visualbasic/complex/StructDefinitionType.vb b/tests/Generator/resource/visualbasic/complex/StructDefinitionType.vb index 529c7f2..9e4b1c5 100644 --- a/tests/Generator/resource/visualbasic/complex/StructDefinitionType.vb +++ b/tests/Generator/resource/visualbasic/complex/StructDefinitionType.vb @@ -3,20 +3,20 @@ Imports System.Text.Json.Serialization ' A struct represents a class/structure with a fix set of defined properties. Public Class StructDefinitionType Inherits DefinitionType - <JsonPropertyName("parent")> - Public Property Parent As ReferencePropertyType - <JsonPropertyName("base")> Public Property Base As Boolean - <JsonPropertyName("properties")> - Public Property Properties As Dictionary(Of String, PropertyType) - <JsonPropertyName("discriminator")> Public Property Discriminator As String <JsonPropertyName("mapping")> Public Property Mapping As Dictionary(Of String, String) + <JsonPropertyName("parent")> + Public Property Parent As ReferencePropertyType + + <JsonPropertyName("properties")> + Public Property Properties As Dictionary(Of String, PropertyType) + End Class diff --git a/tests/Generator/resource/visualbasic/complex/TypeSchema.vb b/tests/Generator/resource/visualbasic/complex/TypeSchema.vb index 3d75200..85f079c 100644 --- a/tests/Generator/resource/visualbasic/complex/TypeSchema.vb +++ b/tests/Generator/resource/visualbasic/complex/TypeSchema.vb @@ -2,12 +2,12 @@ Imports System.Text.Json.Serialization ' TypeSchema specification Public Class TypeSchema - <JsonPropertyName("import")> - Public Property Import As Dictionary(Of String, String) - <JsonPropertyName("definitions")> Public Property Definitions As Dictionary(Of String, DefinitionType) + <JsonPropertyName("import")> + Public Property Import As Dictionary(Of String, String) + <JsonPropertyName("root")> Public Property Root As String