Skip to content

Commit

Permalink
More JSON fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
SebastianStehle committed Jun 21, 2021
1 parent 9926e21 commit 77f8f8f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using System.IO;
using System.Linq;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json.Serialization;
using NJsonSchema;
Expand Down Expand Up @@ -43,12 +44,13 @@ public JsonHelper()
ContractResolver = new CamelCaseExceptDictionaryKeysResolver()
};

jsonSerializerSettings.Converters.Add(new StringEnumConverter());
jsonSerializerSettings.Formatting = Formatting.Indented;

jsonSchemaGeneratorSettings = new JsonSchemaGeneratorSettings
{
FlattenInheritanceHierarchy = true,
SchemaType = SchemaType.JsonSchema,
SchemaType = SchemaType.OpenApi3,
SchemaNameGenerator = new DefaultSchemaNameGenerator(),
SerializerSettings = jsonSerializerSettings
};
Expand Down Expand Up @@ -104,12 +106,9 @@ public void WriteSchema<T>(Stream stream)
{
using (var textWriter = new StreamWriter(stream))
{
using (var jsonWriter = new JsonTextWriter(textWriter))
{
var obj = GetSchema<T>();
var schema = GetSchema<T>();

jsonSerializer.Serialize(jsonWriter, obj);
}
textWriter.Write(schema.ToJson());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public Task GetAllAsync(int batchSize, Func<TEntity, Task> callback, QueryContex
/// <inheritdoc/>
public async Task GetAllAsync(Func<TEntity, Task> callback, int batchSize = 200, QueryContext context = null, CancellationToken ct = default)
{
Guard.Between(10, batchSize, 10_000, nameof(batchSize));
Guard.Between(batchSize, 10, 10_000, nameof(batchSize));
Guard.NotNull(callback, nameof(callback));

var query = new ContentQuery { Top = batchSize };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ public Task<AssetsDto> GetAssetsAsync(string app, AssetQuery query = null, Cance
/// <inheritdoc />
public async Task GetAllAsync(string app, Func<AssetDto, Task> callback, int batchSize = 200, CancellationToken cancellationToken = default)
{
Guard.Between(10, batchSize, 10_000, nameof(batchSize));
Guard.Between(batchSize, 10, 10_000, nameof(batchSize));
Guard.NotNull(callback, nameof(callback));

var query = new AssetQuery { Top = batchSize, Skip = 0 };
Expand Down

0 comments on commit 77f8f8f

Please sign in to comment.