mirror of https://github.com/Squidex/squidex.git
12 changed files with 120 additions and 156 deletions
@ -0,0 +1,50 @@ |
|||
// ==========================================================================
|
|||
// Squidex Headless CMS
|
|||
// ==========================================================================
|
|||
// Copyright (c) Squidex UG (haftungsbeschraenkt)
|
|||
// All rights reserved. Licensed under the MIT license.
|
|||
// ==========================================================================
|
|||
|
|||
using System.Collections.Generic; |
|||
using Microsoft.Extensions.Options; |
|||
using NSwag; |
|||
using NSwag.Generation.Processors; |
|||
using NSwag.Generation.Processors.Contexts; |
|||
using Squidex.Web; |
|||
|
|||
namespace Squidex.Areas.Api.Config.OpenApi |
|||
{ |
|||
public sealed class CommonProcessor : IDocumentProcessor |
|||
{ |
|||
private readonly string version; |
|||
private readonly string backgroundColor = "#3f83df"; |
|||
private readonly string logoUrl; |
|||
private readonly OpenApiExternalDocumentation documentation = new OpenApiExternalDocumentation |
|||
{ |
|||
Url = "https://docs.squidex.io" |
|||
}; |
|||
|
|||
public CommonProcessor(ExposedValues exposedValues, IOptions<UrlsOptions> urlOptions) |
|||
{ |
|||
logoUrl = urlOptions.Value.BuildUrl("images/logo-white.png", false); |
|||
|
|||
if (!exposedValues.TryGetValue("version", out version)) |
|||
{ |
|||
version = "1.0"; |
|||
} |
|||
} |
|||
|
|||
public void Process(DocumentProcessorContext context) |
|||
{ |
|||
context.Document.BasePath = Constants.ApiPrefix; |
|||
|
|||
context.Document.Info.Version = version; |
|||
context.Document.Info.ExtensionData = new Dictionary<string, object> |
|||
{ |
|||
["x-logo"] = new { url = logoUrl, backgroundColor } |
|||
}; |
|||
|
|||
context.Document.ExternalDocumentation = documentation; |
|||
} |
|||
} |
|||
} |
|||
@ -1,37 +0,0 @@ |
|||
// ==========================================================================
|
|||
// Squidex Headless CMS
|
|||
// ==========================================================================
|
|||
// Copyright (c) Squidex UG (haftungsbeschraenkt)
|
|||
// All rights reserved. Licensed under the MIT license.
|
|||
// ==========================================================================
|
|||
|
|||
using System.Collections.Generic; |
|||
using Microsoft.Extensions.Options; |
|||
using NSwag.Generation.Processors; |
|||
using NSwag.Generation.Processors.Contexts; |
|||
using Squidex.Web; |
|||
|
|||
namespace Squidex.Areas.Api.Config.OpenApi |
|||
{ |
|||
public sealed class ThemeProcessor : IDocumentProcessor |
|||
{ |
|||
private const string Background = "#3f83df"; |
|||
|
|||
private readonly string url; |
|||
|
|||
public ThemeProcessor(IOptions<UrlsOptions> urlOptions) |
|||
{ |
|||
url = urlOptions.Value.BuildUrl("images/logo-white.png", false); |
|||
} |
|||
|
|||
public void Process(DocumentProcessorContext context) |
|||
{ |
|||
context.Document.BasePath = Constants.ApiPrefix; |
|||
|
|||
context.Document.Info.ExtensionData = new Dictionary<string, object> |
|||
{ |
|||
["x-logo"] = new { url, backgroundColor = Background } |
|||
}; |
|||
} |
|||
} |
|||
} |
|||
@ -1,31 +0,0 @@ |
|||
// ==========================================================================
|
|||
// Squidex Headless CMS
|
|||
// ==========================================================================
|
|||
// Copyright (c) Squidex UG (haftungsbeschraenkt)
|
|||
// All rights reserved. Licensed under the MIT license.
|
|||
// ==========================================================================
|
|||
|
|||
using NSwag.Generation.Processors; |
|||
using NSwag.Generation.Processors.Contexts; |
|||
using Squidex.Web; |
|||
|
|||
namespace Squidex.Areas.Api.Config.OpenApi |
|||
{ |
|||
public sealed class VersionProcessor : IDocumentProcessor |
|||
{ |
|||
private readonly ExposedValues exposedValues; |
|||
|
|||
public VersionProcessor(ExposedValues exposedValues) |
|||
{ |
|||
this.exposedValues = exposedValues; |
|||
} |
|||
|
|||
public void Process(DocumentProcessorContext context) |
|||
{ |
|||
if (exposedValues.TryGetValue("version", out var version)) |
|||
{ |
|||
context.Document.Info.Version = version; |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -1,6 +1,6 @@ |
|||
The data of the content to be created or updated. |
|||
|
|||
Please note that each field is an object with one entry per language. |
|||
If the field is not localizable you must use `iv` (Invariant Language) as a key. |
|||
If the field is not localizable you must use `iv` (invariant language) as a key. |
|||
|
|||
Read more about it at: https://docs.squidex.io/04-guides/02-api.html |
|||
Loading…
Reference in new issue