-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
36 changed files
with
172 additions
and
171 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Copyright (c) usercode | ||
// https://github.com/usercode/DragonFly | ||
// MIT License | ||
|
||
using DragonFly.Builders; | ||
using DragonFly.API.Exports.Json; | ||
using DragonFly.Core.ContentStructures; | ||
using DragonFly.Storage; | ||
using Microsoft.Extensions.DependencyInjection; | ||
|
||
namespace DragonFly.Client; | ||
|
||
public static class StartupExtensions | ||
{ | ||
public static IDragonFlyBuilder AddRestApi(this IDragonFlyBuilder builder) | ||
{ | ||
builder.Services.AddTransient<ClientContentService>(); | ||
builder.Services.AddTransient<IContentStorage, ClientContentService>(); | ||
builder.Services.AddTransient<IStructureStorage, ClientContentService>(); | ||
builder.Services.AddTransient<IWebHookStorage, ClientContentService>(); | ||
builder.Services.AddTransient<IAssetStorage, ClientContentService>(); | ||
builder.Services.AddTransient<IAssetFolderStorage, ClientContentService>(); | ||
|
||
builder.PostInit<JsonDerivedTypesAction>(); | ||
|
||
return builder; | ||
} | ||
} |
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
43 changes: 0 additions & 43 deletions
43
src/DragonFly.API.Exports/Json/Converters/ArrayOptionJsonConverter.cs
This file was deleted.
Oops, something went wrong.
44 changes: 0 additions & 44 deletions
44
src/DragonFly.API.Exports/Json/Converters/QueryFieldJsonConverter.cs
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// Copyright (c) usercode | ||
// https://github.com/usercode/DragonFly | ||
// MIT License | ||
|
||
using System.Text.Json.Serialization.Metadata; | ||
using DragonFly.AspNetCore.API.Exports.Json; | ||
using DragonFly.Query; | ||
|
||
namespace DragonFly.API.Exports.Json; | ||
|
||
public class JsonDerivedTypesAction : IPostInitialize | ||
{ | ||
public async Task ExecuteAsync(IDragonFlyApi api) | ||
{ | ||
JsonPolymorphismOptions optionsDerivedTypes = new JsonPolymorphismOptions(); | ||
|
||
foreach (Type type in api.ContentField().GetAllOptionsTypes()) | ||
{ | ||
optionsDerivedTypes.DerivedTypes.Add(new JsonDerivedType(type, type.Name)); | ||
} | ||
|
||
JsonPolymorphismOptions queryDerivedTypes = new JsonPolymorphismOptions(); | ||
|
||
foreach (Type type in api.ContentField().GetAllQueryTypes()) | ||
{ | ||
queryDerivedTypes.DerivedTypes.Add(new JsonDerivedType(type, type.Name)); | ||
} | ||
|
||
JsonSerializerDefault.Options.TypeInfoResolver = new DefaultJsonTypeInfoResolver() | ||
{ | ||
Modifiers = | ||
{ | ||
(JsonTypeInfo typeInfo) => | ||
{ | ||
if (typeInfo.Type == typeof(ContentFieldOptions)) | ||
{ | ||
typeInfo.PolymorphismOptions = optionsDerivedTypes; | ||
} | ||
else if (typeInfo.Type == typeof(FieldQuery)) | ||
{ | ||
typeInfo.PolymorphismOptions = queryDerivedTypes; | ||
} | ||
} | ||
} | ||
}; | ||
} | ||
} |
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
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 |
---|---|---|
|
@@ -71,4 +71,5 @@ | |
app.UseDragonFlyManager(); | ||
app.UseSwagger(); | ||
app.UseSwaggerUI(); | ||
app.UseRouting(); | ||
app.Run(); |
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
Oops, something went wrong.