Skip to content

Commit

Permalink
update test
Browse files Browse the repository at this point in the history
  • Loading branch information
chriskapp committed Oct 27, 2024
1 parent d2de613 commit 9c5f097
Show file tree
Hide file tree
Showing 11 changed files with 231 additions and 0 deletions.
18 changes: 18 additions & 0 deletions tests/Generator/resource/csharp/complex/TypeSchema.cs
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; }

}

8 changes: 8 additions & 0 deletions tests/Generator/resource/go/complex/type_schema.go
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"`
}

43 changes: 43 additions & 0 deletions tests/Generator/resource/java/complex/TypeSchema.java
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;
}
}

9 changes: 9 additions & 0 deletions tests/Generator/resource/kotlin/complex/TypeSchema.kt
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
}

71 changes: 71 additions & 0 deletions tests/Generator/resource/php/complex/TypeSchema.php
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();
}
}

14 changes: 14 additions & 0 deletions tests/Generator/resource/python/complex/type_schema.py
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


12 changes: 12 additions & 0 deletions tests/Generator/resource/ruby/complex/type_schema.rb
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

17 changes: 17 additions & 0 deletions tests/Generator/resource/rust/complex/type_schema.rs
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>,

}

13 changes: 13 additions & 0 deletions tests/Generator/resource/swift/complex/TypeSchema.swift
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"
}
}

11 changes: 11 additions & 0 deletions tests/Generator/resource/typescript/complex/TypeSchema.ts
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 tests/Generator/resource/visualbasic/complex/TypeSchema.vb
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

0 comments on commit 9c5f097

Please sign in to comment.