Skip to content

Commit

Permalink
fixed json mappings
Browse files Browse the repository at this point in the history
  • Loading branch information
HristoKolev committed Jan 22, 2022
1 parent ec3a664 commit 97f48f9
Show file tree
Hide file tree
Showing 6 changed files with 225 additions and 46 deletions.
22 changes: 16 additions & 6 deletions increment-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@

VERSION_POSITION=$1

TMP_SOURCE="${BASH_SOURCE[0]}"
while [ -h "$TMP_SOURCE" ]; do
SCRIPT_PATH="$( cd -P "$( dirname "$TMP_SOURCE" )" >/dev/null 2>&1 && pwd )"
TMP_SOURCE="$(readlink "$TMP_SOURCE")"
[[ $TMP_SOURCE != /* ]] && TMP_SOURCE="$SCRIPT_PATH/$TMP_SOURCE"
done
SCRIPT_PATH="$( cd -P "$( dirname "$TMP_SOURCE" )" >/dev/null 2>&1 && pwd )"

set -eu -o pipefail

# Accepts a version string and prints it incremented by one.
# Usage: increment_version <version> [<position>] [<leftmost>]
increment_version() {
Expand Down Expand Up @@ -66,15 +76,15 @@ increment_version() {
return 0
}

FIRST_PROJECT_FILE_PATH=$(find ./ -name '*.csproj' | head -n 1)
VERSION_NUMBER=$(cat $FIRST_PROJECT_FILE_PATH | grep -Eo '<Version>.+</Version>' | grep -Eo '[0-9]+.[0-9]+.[0-9]+')
FIRST_PROJECT_FILE_PATH=$(find "$SCRIPT_PATH" -name '*.csproj' | head -n 1)
VERSION_NUMBER=$(cat "$FIRST_PROJECT_FILE_PATH" | grep -Eo '<Version>.+</Version>' | grep -Eo '[0-9]+.[0-9]+.[0-9]+')

INCREMENTED_VERSION=$(increment_version $VERSION_NUMBER $VERSION_POSITION)

echo "$VERSION_NUMBER => $INCREMENTED_VERSION"

find ./ -name '*.csproj' -print0 | while read -d $'\0' file; do
sed -i -E "s,<Version>.+</Version>,<Version>$INCREMENTED_VERSION</Version>,g" $file
sed -i -E "s,<VersionPrefix>.+</VersionPrefix>,<VersionPrefix>$INCREMENTED_VERSION</VersionPrefix>,g" $file
sed -i -E "s,<PackageVersion>.+</PackageVersion>,<PackageVersion>$INCREMENTED_VERSION</PackageVersion>,g" $file
find "$SCRIPT_PATH" -name '*.csproj' -print0 | while read -d $'\0' file; do
sed -i -E "s,<Version>.+</Version>,<Version>$INCREMENTED_VERSION</Version>,g" "$file"
sed -i -E "s,<VersionPrefix>.+</VersionPrefix>,<VersionPrefix>$INCREMENTED_VERSION</VersionPrefix>,g" "$file"
sed -i -E "s,<PackageVersion>.+</PackageVersion>,<PackageVersion>$INCREMENTED_VERSION</PackageVersion>,g" "$file"
done
43 changes: 35 additions & 8 deletions src/TvDbSharper/TvDbClient.Generated.cs
Original file line number Diff line number Diff line change
Expand Up @@ -866,7 +866,7 @@ public class ArtworkExtendedRecordDto
[JsonProperty("width")]
public long Width { get; set; }

[JsonIgnore]
[JsonProperty("status")]
public object Status { get; set; }
}

Expand Down Expand Up @@ -916,6 +916,30 @@ public class AwardBaseRecordDto

[JsonProperty("name")]
public string Name { get; set; }

[JsonProperty("year")]
public string Year { get; set; }

[JsonProperty("category")]
public string Category { get; set; }

[JsonProperty("isWinner")]
public bool IsWinner { get; set; }

[JsonProperty("details")]
public object Details { get; set; }

[JsonProperty("series")]
public object Series { get; set; }

[JsonProperty("movie")]
public object Movie { get; set; }

[JsonProperty("episode")]
public object Episode { get; set; }

[JsonProperty("character")]
public object Character { get; set; }
}

public class AwardCategoryBaseRecordDto
Expand Down Expand Up @@ -1622,6 +1646,9 @@ public class MovieExtendedRecordDto
[JsonProperty("companies")]
public CompaniesDto Companies { get; set; }

[JsonProperty("translations")]
public TranslationExtendedDto Translations { get; set; }

[JsonProperty("runtime")]
public int Runtime { get; set; }

Expand Down Expand Up @@ -1727,8 +1754,8 @@ public class PeopleExtendedRecordDto
[JsonProperty("overviewTranslations")]
public string[] OverviewTranslations { get; set; }

[JsonIgnore]
public object Translations { get; set; }
[JsonProperty("translations")]
public TranslationExtendedDto Translations { get; set; }
}

public class PeopleTypeDto
Expand Down Expand Up @@ -1951,8 +1978,8 @@ public class SeasonExtendedRecordDto
[JsonProperty("tagOptions")]
public TagOptionDto[] TagOptions { get; set; }

[JsonIgnore]
public TranslationDto[] Translations { get; set; }
[JsonProperty("translations")]
public TranslationExtendedDto Translations { get; set; }
}

public class SeasonTypeDto
Expand Down Expand Up @@ -2156,7 +2183,7 @@ public class SeriesExtendedRecordDto
public TrailerDto[] Trailers { get; set; }

[JsonProperty("translations")]
public TranslationExtendedDto[] Translations { get; set; }
public TranslationExtendedDto Translations { get; set; }

[JsonProperty("lastUpdated")]
public string LastUpdated { get; set; }
Expand Down Expand Up @@ -2308,8 +2335,8 @@ public class TranslationExtendedDto
[JsonProperty("overviewTranslations")]
public TranslationDto[] OverviewTranslations { get; set; }

[JsonProperty("alias")]
public string[] Alias { get; set; }
[JsonProperty("aliases")]
public string[] Aliases { get; set; }
}

public class TagOptionEntityDto
Expand Down
8 changes: 4 additions & 4 deletions src/TvDbSharper/TvDbSharper.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<Description>TvDbSharper is fully featured modern REST client for the TheTVDB API v4</Description>
<VersionPrefix>4.0.6</VersionPrefix>
<VersionPrefix>4.0.7</VersionPrefix>
<Authors>HristoKolev</Authors>
<TargetFramework>netstandard1.1</TargetFramework>
<NoWarn>$(NoWarn);1591</NoWarn>
Expand All @@ -19,12 +19,12 @@
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
<GenerateAssemblyDescriptionAttribute>false</GenerateAssemblyDescriptionAttribute>
<Version>4.0.6</Version>
<PackageVersion>4.0.6</PackageVersion>
<Version>4.0.7</Version>
<PackageVersion>4.0.7</PackageVersion>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1"/>
</ItemGroup>

</Project>
149 changes: 146 additions & 3 deletions test/GenerateDto/CodeBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,12 @@ public static class CodeBuilder
OverrideType = "int?",
},
new()
{
MatchClassName = "SeasonExtendedRecordDto",
MatchFieldName = "translations",
OverrideType = "TranslationExtendedDto",
},
new()
{
MatchClassName = "StatusDto",
MatchFieldName = "id",
Expand All @@ -376,6 +382,47 @@ public static class CodeBuilder
MatchFieldName = "averageRuntime",
OverrideType = "int?",
},
new()
{
MatchClassName = "ParentCompanyDto",
MatchFieldName = "id",
OverrideType = "long?",
},
new()
{
MatchClassName = "CompanyRelationShipDto",
MatchFieldName = "id",
OverrideType = "long?",
},
new()
{
MatchClassName = "StudioBaseRecordDto",
MatchFieldName = "parentStudio",
OverrideType = "int?",
},
new()
{
MatchClassName = "StudioBaseRecordDto",
MatchFieldName = "parentStudio",
OverrideType = "int?",
},
new()
{
MatchClassName = "TranslationExtendedDto",
MatchFieldName = "alias",
OverrideFieldName = "aliases",
OverridePropertyName = "Aliases",
OverridePropertyAttributes = new List<string>
{
"[JsonProperty(\"aliases\")]",
},
},
new()
{
MatchClassName = "SeriesExtendedRecordDto",
MatchFieldName = "translations",
OverrideType = "TranslationExtendedDto",
},
};

private static readonly Dictionary<string, List<PropertyModel>> ExtraProperties = new()
Expand All @@ -390,7 +437,7 @@ public static class CodeBuilder
PropertyType = "object",
PropertyAttributes = new List<string>
{
"[JsonIgnore]",
"[JsonProperty(\"status\")]",
},
},
}
Expand Down Expand Up @@ -508,6 +555,16 @@ public static class CodeBuilder
{
"MovieExtendedRecordDto", new List<PropertyModel>
{
new()
{
FieldName = "translations",
PropertyName = "Translations",
PropertyType = "TranslationExtendedDto",
PropertyAttributes = new List<string>
{
"[JsonProperty(\"translations\")]",
},
},
new()
{
FieldName = "runtime",
Expand All @@ -518,6 +575,7 @@ public static class CodeBuilder
"[JsonProperty(\"runtime\")]",
},
},

new()
{
FieldName = "lastUpdated",
Expand Down Expand Up @@ -557,10 +615,10 @@ public static class CodeBuilder
{
FieldName = "translations",
PropertyName = "Translations",
PropertyType = "object",
PropertyType = "TranslationExtendedDto",
PropertyAttributes = new List<string>
{
"[JsonIgnore]",
"[JsonProperty(\"translations\")]",
},
},
}
Expand Down Expand Up @@ -670,6 +728,91 @@ public static class CodeBuilder
},
}
},
{
"AwardBaseRecordDto", new List<PropertyModel>
{
new()
{
FieldName = "year",
PropertyName = "Year",
PropertyType = "string",
PropertyAttributes = new List<string>
{
"[JsonProperty(\"year\")]",
},
},
new()
{
FieldName = "category",
PropertyName = "Category",
PropertyType = "string",
PropertyAttributes = new List<string>
{
"[JsonProperty(\"category\")]",
},
},
new()
{
FieldName = "isWinner",
PropertyName = "IsWinner",
PropertyType = "bool",
PropertyAttributes = new List<string>
{
"[JsonProperty(\"isWinner\")]",
},
},
new()
{
FieldName = "details",
PropertyName = "Details",
PropertyType = "object",
PropertyAttributes = new List<string>
{
"[JsonProperty(\"details\")]",
},
},
new()
{
FieldName = "series",
PropertyName = "Series",
PropertyType = "object",
PropertyAttributes = new List<string>
{
"[JsonProperty(\"series\")]",
},
},
new()
{
FieldName = "movie",
PropertyName = "Movie",
PropertyType = "object",
PropertyAttributes = new List<string>
{
"[JsonProperty(\"movie\")]",
},
},
new()
{
FieldName = "episode",
PropertyName = "Episode",
PropertyType = "object",
PropertyAttributes = new List<string>
{
"[JsonProperty(\"episode\")]",
},
},
new()
{
FieldName = "character",
PropertyName = "Character",
PropertyType = "object",
PropertyAttributes = new List<string>
{
"[JsonProperty(\"character\")]",
},
},
}
},
};

private static readonly Dictionary<string, string> MethodReturnTypeOverrides = new()
Expand Down
4 changes: 2 additions & 2 deletions test/GenerateDto/GenerateDto.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="YamlDotNet" Version="11.2.1" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1"/>
<PackageReference Include="YamlDotNet" Version="11.2.1"/>
</ItemGroup>

</Project>
Loading

0 comments on commit 97f48f9

Please sign in to comment.