Skip to content

Commit

Permalink
Merge branch 'RicoSuter:master' into annotations-without-stripping-wh…
Browse files Browse the repository at this point in the history
…itespace-on-right-side
  • Loading branch information
martindamgaardlorensen authored Aug 23, 2024
2 parents 41cb7ff + 9bf8f69 commit 0fafc11
Show file tree
Hide file tree
Showing 12 changed files with 333 additions and 19 deletions.
4 changes: 2 additions & 2 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@ $DotNetGlobalFile = "$PSScriptRoot\\global.json"
$DotNetInstallUrl = "https://dot.net/v1/dotnet-install.ps1"
$DotNetChannel = "STS"

$env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE = 1
$env:DOTNET_CLI_TELEMETRY_OPTOUT = 1
$env:DOTNET_MULTILEVEL_LOOKUP = 0
$env:DOTNET_NOLOGO = 1

###########################################################################
# EXECUTION
Expand Down Expand Up @@ -61,6 +60,7 @@ else {
ExecSafe { & powershell $DotNetInstallFile -InstallDir $DotNetDirectory -Version $DotNetVersion -NoPath }
}
$env:DOTNET_EXE = "$DotNetDirectory\dotnet.exe"
$env:PATH = "$DotNetDirectory;$env:PATH"
}

Write-Output "Microsoft (R) .NET SDK version $(& $env:DOTNET_EXE --version)"
Expand Down
6 changes: 3 additions & 3 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ DOTNET_INSTALL_URL="https://dot.net/v1/dotnet-install.sh"
DOTNET_CHANNEL="STS"

export DOTNET_CLI_TELEMETRY_OPTOUT=1
export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
export DOTNET_MULTILEVEL_LOOKUP=0
export DOTNET_NOLOGO=1

###########################################################################
# EXECUTION
Expand Down Expand Up @@ -54,11 +53,12 @@ else
"$DOTNET_INSTALL_FILE" --install-dir "$DOTNET_DIRECTORY" --version "$DOTNET_VERSION" --no-path
fi
export DOTNET_EXE="$DOTNET_DIRECTORY/dotnet"
export PATH="$DOTNET_DIRECTORY:$PATH"
fi

echo "Microsoft (R) .NET SDK version $("$DOTNET_EXE" --version)"

if [[ ! -z ${NUKE_ENTERPRISE_TOKEN+x} && "NUKE_ENTERPRISE_TOKEN" != "" ]]; then
if [[ ! -z ${NUKE_ENTERPRISE_TOKEN+x} && "$NUKE_ENTERPRISE_TOKEN" != "" ]]; then
"$DOTNET_EXE" nuget remove source "nuke-enterprise" &>/dev/null || true
"$DOTNET_EXE" nuget add source "https://f.feedz.io/nuke/enterprise/nuget" --name "nuke-enterprise" --username "PAT" --password "$NUKE_ENTERPRISE_TOKEN" --store-password-in-clear-text &>/dev/null || true
fi
Expand Down
5 changes: 4 additions & 1 deletion build/_build.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
<NukeRootDirectory>..</NukeRootDirectory>
<NukeScriptDirectory>..</NukeScriptDirectory>
<NukeTelemetryVersion>1</NukeTelemetryVersion>
<NukeExcludeConfig>true</NukeExcludeConfig>
<NukeExcludeDirectoryBuild>true</NukeExcludeDirectoryBuild>
<NukeExcludeLogs>true</NukeExcludeLogs>
<IsPackable>false</IsPackable>
<EnableUnsafeBinaryFormatterSerialization>true</EnableUnsafeBinaryFormatterSerialization>
<ManagePackageVersionsCentrally>false</ManagePackageVersionsCentrally>
Expand All @@ -18,7 +21,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Nuke.Common" Version="7.0.6" />
<PackageReference Include="Nuke.Common" Version="8.0.0" />
<PackageDownload Include="NuGet.CommandLine" Version="[5.11.0]" />
</ItemGroup>

Expand Down
4 changes: 2 additions & 2 deletions src/NJsonSchema.CodeGeneration.Tests/EnumGenerationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,8 @@ public async Task When_enum_has_string_value_then_TS_code_has_string_value()
var code = generator.GenerateFile("MyClass");

//// Assert
Assert.Contains("_0562 = <any>\"0562\",", code);
Assert.Contains("_0532 = <any>\"0532\",", code);
Assert.Contains("_0562 = \"0562\",", code);
Assert.Contains("_0532 = \"0532\",", code);
}

public class ClassWithStringEnum
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
//----------------------
// <auto-generated>
// </auto-generated>
//----------------------







export interface Base {
Type: EBase;
}

export enum EBase {
OneChild = "OneChild",
SecondChild = "SecondChild",
}

export interface OneChild extends Base {
A: string;
Type: EBase.OneChild;
}

export interface SecondChild extends Base {
B: string;
Type: EBase.SecondChild;
}

export interface MyClass {
Child: Base;
Children: Base[];
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
//----------------------
// <auto-generated>
// </auto-generated>
//----------------------







export interface Base {
Type: EBase;
}

export type EBase = "OneChild" | "SecondChild";

export interface OneChild extends Base {
A: string;
Type: 'OneChild';
}

export interface SecondChild extends Base {
B: string;
Type: 'SecondChild';
}

export interface MyClass {
Child: Base;
Children: Base[];
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
//----------------------
// <auto-generated>
// </auto-generated>
//----------------------







export abstract class Base implements IBase {

protected _discriminator: string;

constructor(data?: IBase) {
if (data) {
for (var property in data) {
if (data.hasOwnProperty(property))
(<any>this)[property] = (<any>data)[property];
}
}
this._discriminator = "Base";
}

init(_data?: any) {
}

static fromJS(data: any): Base {
data = typeof data === 'object' ? data : {};
if (data["Type"] === "OneChild") {
let result = new OneChild();
result.init(data);
return result;
}
if (data["Type"] === "SecondChild") {
let result = new SecondChild();
result.init(data);
return result;
}
throw new Error("The abstract class 'Base' cannot be instantiated.");
}

toJSON(data?: any) {
data = typeof data === 'object' ? data : {};
data["Type"] = this._discriminator;
return data;
}
}

export interface IBase {
}

export class OneChild extends Base implements IOneChild {
a: string;
type: EBase;

constructor(data?: IOneChild) {
super(data);
this._discriminator = "OneChild";
}

init(_data?: any) {
super.init(_data);
if (_data) {
this.a = _data["A"];
this.type = _data["Type"];
}
}

static fromJS(data: any): OneChild {
data = typeof data === 'object' ? data : {};
let result = new OneChild();
result.init(data);
return result;
}

toJSON(data?: any) {
data = typeof data === 'object' ? data : {};
data["A"] = this.a;
data["Type"] = this.type;
super.toJSON(data);
return data;
}
}

export interface IOneChild extends IBase {
a: string;
type: EBase;
}

export enum EBase {
OneChild = "OneChild",
SecondChild = "SecondChild",
}

export class SecondChild extends Base implements ISecondChild {
b: string;
type: EBase;

constructor(data?: ISecondChild) {
super(data);
this._discriminator = "SecondChild";
}

init(_data?: any) {
super.init(_data);
if (_data) {
this.b = _data["B"];
this.type = _data["Type"];
}
}

static fromJS(data: any): SecondChild {
data = typeof data === 'object' ? data : {};
let result = new SecondChild();
result.init(data);
return result;
}

toJSON(data?: any) {
data = typeof data === 'object' ? data : {};
data["B"] = this.b;
data["Type"] = this.type;
super.toJSON(data);
return data;
}
}

export interface ISecondChild extends IBase {
b: string;
type: EBase;
}

export class MyClass implements IMyClass {
child: OneChild | SecondChild;
children: (OneChild | SecondChild)[];

constructor(data?: IMyClass) {
if (data) {
for (var property in data) {
if (data.hasOwnProperty(property))
(<any>this)[property] = (<any>data)[property];
}
}
}

init(_data?: any) {
if (_data) {
this.child = _data["Child"] ? OneChild | SecondChild.fromJS(_data["Child"]) : <any>undefined;
if (Array.isArray(_data["Children"])) {
this.children = [] as any;
for (let item of _data["Children"])
this.children.push(OneChild | SecondChild.fromJS(item));
}
}
}

static fromJS(data: any): MyClass {
data = typeof data === 'object' ? data : {};
let result = new MyClass();
result.init(data);
return result;
}

toJSON(data?: any) {
data = typeof data === 'object' ? data : {};
data["Child"] = this.child ? this.child.toJSON() : <any>undefined;
if (Array.isArray(this.children)) {
data["Children"] = [];
for (let item of this.children)
data["Children"].push(item.toJSON());
}
return data;
}
}

export interface IMyClass {
child: OneChild | SecondChild;
children: (OneChild | SecondChild)[];
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
//----------------------
// <auto-generated>
// </auto-generated>
//----------------------







export interface Base {
Type: string;
}

export interface OneChild extends Base {
A: string;
Type: EBase.OneChild;
}

export enum EBase {
OneChild = "OneChild",
SecondChild = "SecondChild",
}

export interface SecondChild extends Base {
B: string;
Type: EBase.SecondChild;
}

export interface MyClass {
Child: OneChild | SecondChild;
Children: (OneChild | SecondChild)[];
}
Loading

0 comments on commit 0fafc11

Please sign in to comment.