-
-
Notifications
You must be signed in to change notification settings - Fork 538
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Dereference actual type schema (#798)
* Dereference actual type schema * Fix and improve resolvers
- Loading branch information
Showing
11 changed files
with
56 additions
and
37 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
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
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 |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
// <author>Rico Suter, [email protected]</author> | ||
//----------------------------------------------------------------------- | ||
|
||
using System; | ||
using System.Linq; | ||
|
||
namespace NJsonSchema.CodeGeneration.CSharp | ||
|
@@ -54,12 +55,15 @@ public override string Resolve(JsonSchema4 schema, bool isNullable, string typeN | |
/// <returns>The type name.</returns> | ||
public string Resolve(JsonSchema4 schema, bool isNullable, string typeNameHint, bool checkForExistingSchema) | ||
{ | ||
schema = schema.ActualSchema; | ||
if (schema == null) | ||
throw new ArgumentNullException(nameof(schema)); | ||
|
||
schema = GetResolvableSchema(schema); | ||
|
||
if (schema == ExceptionSchema) | ||
return "System.Exception"; | ||
|
||
if (schema.IsAnyType) | ||
if (schema.ActualTypeSchema.IsAnyType) | ||
return "object"; | ||
|
||
var type = schema.Type; | ||
|
@@ -178,7 +182,7 @@ private string ResolveArrayOrTuple(JsonSchema4 schema) | |
if (schema.Items != null && schema.Items.Count > 0) | ||
{ | ||
var tupleTypes = schema.Items | ||
.Select(i => Resolve(i.ActualSchema, false, null)) | ||
.Select(i => Resolve(i, false, null)) | ||
.ToArray(); | ||
|
||
return string.Format("System.Tuple<" + string.Join(", ", tupleTypes) + ">"); | ||
|
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
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
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
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
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
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
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
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