-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
231 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using System.Text.Json.Serialization; | ||
|
||
/// <summary> | ||
/// TypeSchema specification | ||
/// </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("root")] | ||
public string? Root { get; set; } | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
|
||
// TypeSchema specification | ||
type TypeSchema struct { | ||
Import map[string]string `json:"import"` | ||
Definitions map[string]DefinitionType `json:"definitions"` | ||
Root string `json:"root"` | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
|
||
import com.fasterxml.jackson.annotation.JsonGetter; | ||
import com.fasterxml.jackson.annotation.JsonSetter; | ||
|
||
/** | ||
* TypeSchema specification | ||
*/ | ||
public class TypeSchema { | ||
private java.util.Map<String, String> _import; | ||
private java.util.Map<String, DefinitionType> definitions; | ||
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; | ||
} | ||
|
||
@JsonGetter("definitions") | ||
public java.util.Map<String, DefinitionType> getDefinitions() { | ||
return this.definitions; | ||
} | ||
|
||
@JsonSetter("root") | ||
public void setRoot(String root) { | ||
this.root = root; | ||
} | ||
|
||
@JsonGetter("root") | ||
public String getRoot() { | ||
return this.root; | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/** | ||
* TypeSchema specification | ||
*/ | ||
open class TypeSchema { | ||
@JsonProperty("import") var import: Map<String, String>? = null | ||
@JsonProperty("definitions") var definitions: Map<String, DefinitionType>? = null | ||
@JsonProperty("root") var root: String? = null | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
<?php | ||
|
||
declare(strict_types = 1); | ||
|
||
use PSX\Schema\Attribute\Description; | ||
|
||
#[Description('TypeSchema specification')] | ||
class TypeSchema implements \JsonSerializable, \PSX\Record\RecordableInterface | ||
{ | ||
/** | ||
* @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 | ||
*/ | ||
public function setImport(?\PSX\Record\Record $import) : void | ||
{ | ||
$this->import = $import; | ||
} | ||
/** | ||
* @return \PSX\Record\Record<string>|null | ||
*/ | ||
public function getImport() : ?\PSX\Record\Record | ||
{ | ||
return $this->import; | ||
} | ||
/** | ||
* @param \PSX\Record\Record<DefinitionType>|null $definitions | ||
*/ | ||
public function setDefinitions(?\PSX\Record\Record $definitions) : void | ||
{ | ||
$this->definitions = $definitions; | ||
} | ||
/** | ||
* @return \PSX\Record\Record<DefinitionType>|null | ||
*/ | ||
public function getDefinitions() : ?\PSX\Record\Record | ||
{ | ||
return $this->definitions; | ||
} | ||
public function setRoot(?string $root) : void | ||
{ | ||
$this->root = $root; | ||
} | ||
public function getRoot() : ?string | ||
{ | ||
return $this->root; | ||
} | ||
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('root', $this->root); | ||
return $record; | ||
} | ||
public function jsonSerialize() : object | ||
{ | ||
return (object) $this->toRecord()->getAll(); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
from pydantic import BaseModel, Field, GetCoreSchemaHandler | ||
from pydantic_core import CoreSchema, core_schema | ||
from typing import Any, Dict, Generic, List, Optional, TypeVar, UserList, UserDict | ||
from .definition_type import DefinitionType | ||
|
||
|
||
# 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") | ||
root: Optional[str] = Field(default=None, alias="root") | ||
pass | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
|
||
# TypeSchema specification | ||
class TypeSchema | ||
attr_accessor :import, :definitions, :root | ||
|
||
def initialize(import, definitions, root) | ||
@import = import | ||
@definitions = definitions | ||
@root = root | ||
end | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
use serde::{Serialize, Deserialize}; | ||
use definition_type::DefinitionType; | ||
|
||
// TypeSchema specification | ||
#[derive(Serialize, Deserialize)] | ||
pub struct TypeSchema { | ||
#[serde(rename = "import")] | ||
import: Option<HashMap<String, String>>, | ||
|
||
#[serde(rename = "definitions")] | ||
definitions: Option<HashMap<String, DefinitionType>>, | ||
|
||
#[serde(rename = "root")] | ||
root: Option<String>, | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// TypeSchema specification | ||
class TypeSchema: Codable { | ||
var _import: Dictionary<String, String> | ||
var definitions: Dictionary<String, DefinitionType> | ||
var root: String | ||
|
||
enum CodingKeys: String, CodingKey { | ||
case _import = "import" | ||
case definitions = "definitions" | ||
case root = "root" | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import {DefinitionType} from "./DefinitionType"; | ||
|
||
/** | ||
* TypeSchema specification | ||
*/ | ||
export interface TypeSchema { | ||
import?: Map<string, string> | ||
definitions?: Map<string, DefinitionType> | ||
root?: string | ||
} | ||
|
15 changes: 15 additions & 0 deletions
15
tests/Generator/resource/visualbasic/complex/TypeSchema.vb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
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("root")> | ||
Public Property Root As String | ||
|
||
End Class | ||
|