mirror of https://github.com/Squidex/squidex.git
Browse Source
* Temp * Fix backup and warnings. * Fix tests * Another test fix. * Fix resolve url. * Fix tests and add headers. * Another test fix. * Add some comments.pull/1005/head
committed by
GitHub
107 changed files with 1318 additions and 644 deletions
@ -0,0 +1,26 @@ |
|||
// ==========================================================================
|
|||
// Squidex Headless CMS
|
|||
// ==========================================================================
|
|||
// Copyright (c) Squidex UG (haftungsbeschraenkt)
|
|||
// All rights reserved. Licensed under the MIT license.
|
|||
// ==========================================================================
|
|||
|
|||
using GraphQL; |
|||
using GraphQL.Types; |
|||
using GraphQLParser.AST; |
|||
|
|||
namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types.Directives; |
|||
|
|||
public sealed class OptimizeFieldQueriesDirective : Directive |
|||
{ |
|||
public OptimizeFieldQueriesDirective() |
|||
: base("optimizeFieldQueries", DirectiveLocation.Field, DirectiveLocation.FragmentSpread, DirectiveLocation.InlineFragment) |
|||
{ |
|||
Description = "Enable Query Optimizations"; |
|||
} |
|||
|
|||
public static bool IsApplied(IResolveFieldContext context) |
|||
{ |
|||
return context.GetDirective("optimizeFieldQueries") != null; |
|||
} |
|||
} |
|||
@ -0,0 +1,101 @@ |
|||
// ==========================================================================
|
|||
// Squidex Headless CMS
|
|||
// ==========================================================================
|
|||
// Copyright (c) Squidex UG (haftungsbeschraenkt)
|
|||
// All rights reserved. Licensed under the MIT license.
|
|||
// ==========================================================================
|
|||
|
|||
using NJsonSchema; |
|||
using NSwag; |
|||
using NSwag.Annotations; |
|||
using NSwag.Generation.Processors; |
|||
using NSwag.Generation.Processors.Contexts; |
|||
using Squidex.Domain.Apps.Entities; |
|||
using Squidex.Domain.Apps.Entities.Contents; |
|||
|
|||
#pragma warning disable MA0048 // File name must match type name
|
|||
|
|||
namespace Squidex.Areas.Api.Config.OpenApi; |
|||
|
|||
public class AcceptHeader |
|||
{ |
|||
public sealed class UnpublishedAttribute : BaseAttribute |
|||
{ |
|||
public UnpublishedAttribute() |
|||
: base(ContentHeaders.Unpublished, "Return unpublished content items.", JsonObjectType.Boolean) |
|||
{ |
|||
} |
|||
} |
|||
|
|||
public sealed class FieldsAttribute : BaseAttribute |
|||
{ |
|||
public FieldsAttribute() |
|||
: base(ContentHeaders.Fields, "The list of content fields (comma-separated).", JsonObjectType.String) |
|||
{ |
|||
} |
|||
} |
|||
|
|||
public sealed class FlattenAttribute : BaseAttribute |
|||
{ |
|||
public FlattenAttribute() |
|||
: base(ContentHeaders.Flatten, "Provide the data as flat object.", JsonObjectType.Boolean) |
|||
{ |
|||
} |
|||
} |
|||
|
|||
public sealed class LanguagesAttribute : BaseAttribute |
|||
{ |
|||
public LanguagesAttribute() |
|||
: base(ContentHeaders.Languages, "The list of languages to resolve (comma-separated).") |
|||
{ |
|||
} |
|||
} |
|||
|
|||
public sealed class NoTotalAttribute : BaseAttribute |
|||
{ |
|||
public NoTotalAttribute() |
|||
: base(ContextHeaders.NoTotal, "Do not return the total amount.", JsonObjectType.Boolean) |
|||
{ |
|||
} |
|||
} |
|||
|
|||
public sealed class NoSlowTotalAttribute : BaseAttribute |
|||
{ |
|||
public NoSlowTotalAttribute() |
|||
: base(ContextHeaders.NoSlowTotal, "Do not return the total amount, if it would be slow.", JsonObjectType.Boolean) |
|||
{ |
|||
} |
|||
} |
|||
|
|||
public abstract class BaseAttribute : OpenApiOperationProcessorAttribute |
|||
{ |
|||
protected BaseAttribute(string name, string description, JsonObjectType schemaType = JsonObjectType.String) |
|||
: base(typeof(Processor), name, description, schemaType) |
|||
{ |
|||
} |
|||
|
|||
#pragma warning disable IDE1006 // Naming Styles
|
|||
public record Processor(string name, string description, JsonObjectType schemaType) : IOperationProcessor |
|||
#pragma warning restore IDE1006 // Naming Styles
|
|||
{ |
|||
public bool Process(OperationProcessorContext context) |
|||
{ |
|||
var parameter = new OpenApiParameter |
|||
{ |
|||
Name = name, |
|||
Kind = OpenApiParameterKind.Header, |
|||
Schema = new JsonSchema |
|||
{ |
|||
Type = schemaType |
|||
}, |
|||
Description = description |
|||
}; |
|||
|
|||
context.OperationDescription.Operation.Parameters.Add(parameter); |
|||
context.OperationDescription.Operation.SetPositions(); |
|||
|
|||
return true; |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -1,99 +0,0 @@ |
|||
// ==========================================================================
|
|||
// Squidex Headless CMS
|
|||
// ==========================================================================
|
|||
// Copyright (c) Squidex UG (haftungsbeschraenkt)
|
|||
// All rights reserved. Licensed under the MIT license.
|
|||
// ==========================================================================
|
|||
|
|||
using NJsonSchema; |
|||
using NSwag; |
|||
using NSwag.Annotations; |
|||
using NSwag.Generation.Processors; |
|||
using NSwag.Generation.Processors.Contexts; |
|||
using Squidex.Domain.Apps.Entities; |
|||
using Squidex.Domain.Apps.Entities.Contents; |
|||
|
|||
#pragma warning disable MA0048 // File name must match type name
|
|||
|
|||
namespace Squidex.Areas.Api.Config.OpenApi; |
|||
|
|||
public sealed class AcceptHeader_Unpublished : AcceptHeaderAttribute |
|||
{ |
|||
public AcceptHeader_Unpublished() |
|||
: base(ContentHeaders.Unpublished, "Return unpublished content items.", JsonObjectType.Boolean) |
|||
{ |
|||
} |
|||
} |
|||
|
|||
public sealed class AcceptHeader_Flatten : AcceptHeaderAttribute |
|||
{ |
|||
public AcceptHeader_Flatten() |
|||
: base(ContentHeaders.Flatten, "Provide the data as flat object.", JsonObjectType.Boolean) |
|||
{ |
|||
} |
|||
} |
|||
|
|||
public sealed class AcceptHeader_Languages : AcceptHeaderAttribute |
|||
{ |
|||
public AcceptHeader_Languages() |
|||
: base(ContentHeaders.Languages, "Only resolve these languages (comma-separated).") |
|||
{ |
|||
} |
|||
} |
|||
|
|||
public sealed class AcceptHeader_NoTotal : AcceptHeaderAttribute |
|||
{ |
|||
public AcceptHeader_NoTotal() |
|||
: base(ContextHeaders.NoTotal, "Do not return the total amount.", JsonObjectType.Boolean) |
|||
{ |
|||
} |
|||
} |
|||
|
|||
public sealed class AcceptHeader_NoSlowTotal : AcceptHeaderAttribute |
|||
{ |
|||
public AcceptHeader_NoSlowTotal() |
|||
: base(ContextHeaders.NoSlowTotal, "Do not return the total amount, if it would be slow.", JsonObjectType.Boolean) |
|||
{ |
|||
} |
|||
} |
|||
|
|||
public class AcceptHeaderAttribute : OpenApiOperationProcessorAttribute |
|||
{ |
|||
public AcceptHeaderAttribute(string name, string description, JsonObjectType schemaType = JsonObjectType.String) |
|||
: base(typeof(Processor), name, description, schemaType) |
|||
{ |
|||
} |
|||
|
|||
public sealed class Processor : IOperationProcessor |
|||
{ |
|||
private readonly string name; |
|||
private readonly string description; |
|||
private readonly JsonObjectType schemaType; |
|||
|
|||
public Processor(string name, string description, JsonObjectType schemaType) |
|||
{ |
|||
this.name = name; |
|||
this.description = description; |
|||
this.schemaType = schemaType; |
|||
} |
|||
|
|||
public bool Process(OperationProcessorContext context) |
|||
{ |
|||
var parameter = new OpenApiParameter |
|||
{ |
|||
Name = name, |
|||
Kind = OpenApiParameterKind.Header, |
|||
Schema = new JsonSchema |
|||
{ |
|||
Type = schemaType |
|||
}, |
|||
Description = description |
|||
}; |
|||
|
|||
context.OperationDescription.Operation.Parameters.Add(parameter); |
|||
context.OperationDescription.Operation.SetPositions(); |
|||
|
|||
return true; |
|||
} |
|||
} |
|||
} |
|||
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue