Browse Source

Fix in documentation.

pull/400/head
Sebastian Stehle 7 years ago
parent
commit
f1aeb2c997
  1. 3
      src/Squidex/Areas/Api/Config/OpenApi/OpenApiServices.cs
  2. 2
      src/Squidex/Areas/Api/Config/OpenApi/ThemeProcessor.cs
  3. 31
      src/Squidex/Areas/Api/Config/OpenApi/VersionProcessor.cs
  4. 9
      src/Squidex/Areas/Api/Controllers/Contents/Generator/SchemasOpenApiGenerator.cs
  5. 13
      src/Squidex/Areas/Api/Views/Shared/Docs.cshtml
  6. 3
      src/Squidex/Docs/schemabody.md
  7. 3
      src/Squidex/Pipeline/OpenApi/NSwagHelper.cs

3
src/Squidex/Areas/Api/Config/OpenApi/OpenApiServices.cs

@ -32,6 +32,9 @@ namespace Squidex.Areas.Api.Config.OpenApi
services.AddSingletonAs<ThemeProcessor>() services.AddSingletonAs<ThemeProcessor>()
.As<IDocumentProcessor>(); .As<IDocumentProcessor>();
services.AddSingletonAs<VersionProcessor>()
.As<IDocumentProcessor>();
services.AddSingletonAs<XmlTagProcessor>() services.AddSingletonAs<XmlTagProcessor>()
.As<IDocumentProcessor>(); .As<IDocumentProcessor>();

2
src/Squidex/Areas/Api/Config/OpenApi/ThemeProcessor.cs

@ -26,7 +26,7 @@ namespace Squidex.Areas.Api.Config.OpenApi
public void Process(DocumentProcessorContext context) public void Process(DocumentProcessorContext context)
{ {
context.Document.BasePath = $"{Constants.ApiPrefix}/"; context.Document.BasePath = Constants.ApiPrefix;
context.Document.Info.ExtensionData = new Dictionary<string, object> context.Document.Info.ExtensionData = new Dictionary<string, object>
{ {

31
src/Squidex/Areas/Api/Config/OpenApi/VersionProcessor.cs

@ -0,0 +1,31 @@
// ==========================================================================
// 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;
}
}
}
}

9
src/Squidex/Areas/Api/Controllers/Contents/Generator/SchemasOpenApiGenerator.cs

@ -9,7 +9,6 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Options;
using Namotion.Reflection; using Namotion.Reflection;
using NJsonSchema; using NJsonSchema;
using NJsonSchema.Generation; using NJsonSchema.Generation;
@ -23,23 +22,19 @@ using Squidex.Domain.Apps.Entities.Apps;
using Squidex.Domain.Apps.Entities.Schemas; using Squidex.Domain.Apps.Entities.Schemas;
using Squidex.Infrastructure; using Squidex.Infrastructure;
using Squidex.Pipeline.OpenApi; using Squidex.Pipeline.OpenApi;
using Squidex.Web;
namespace Squidex.Areas.Api.Controllers.Contents.Generator namespace Squidex.Areas.Api.Controllers.Contents.Generator
{ {
public sealed class SchemasOpenApiGenerator public sealed class SchemasOpenApiGenerator
{ {
private readonly UrlsOptions urlOptions;
private readonly OpenApiDocumentGeneratorSettings settings = new OpenApiDocumentGeneratorSettings(); private readonly OpenApiDocumentGeneratorSettings settings = new OpenApiDocumentGeneratorSettings();
private OpenApiSchemaGenerator schemaGenerator; private OpenApiSchemaGenerator schemaGenerator;
private OpenApiDocument document; private OpenApiDocument document;
private JsonSchema statusSchema; private JsonSchema statusSchema;
private JsonSchemaResolver schemaResolver; private JsonSchemaResolver schemaResolver;
public SchemasOpenApiGenerator(IOptions<UrlsOptions> urlOptions, IEnumerable<IDocumentProcessor> documentProcessors) public SchemasOpenApiGenerator(IEnumerable<IDocumentProcessor> documentProcessors)
{ {
this.urlOptions = urlOptions.Value;
settings.ConfigureSchemaSettings(); settings.ConfigureSchemaSettings();
foreach (var processor in documentProcessors) foreach (var processor in documentProcessors)
@ -50,7 +45,7 @@ namespace Squidex.Areas.Api.Controllers.Contents.Generator
public OpenApiDocument Generate(HttpContext httpContext, IAppEntity app, IEnumerable<ISchemaEntity> schemas) public OpenApiDocument Generate(HttpContext httpContext, IAppEntity app, IEnumerable<ISchemaEntity> schemas)
{ {
document = NSwagHelper.CreateApiDocument(httpContext, urlOptions, app.Name); document = NSwagHelper.CreateApiDocument(httpContext, app.Name);
schemaGenerator = new OpenApiSchemaGenerator(settings); schemaGenerator = new OpenApiSchemaGenerator(settings);
schemaResolver = new OpenApiSchemaResolver(document, settings); schemaResolver = new OpenApiSchemaResolver(document, settings);

13
src/Squidex/Areas/Api/Views/Shared/Docs.cshtml

@ -17,8 +17,19 @@
</style> </style>
</head> </head>
<body> <body>
<redoc spec-url="@Url.Content(Model.Specification)"></redoc> <div id="redoc-container"></div>
<script src="https://cdn.jsdelivr.net/npm/redoc@next/bundles/redoc.standalone.js"></script> <script src="https://cdn.jsdelivr.net/npm/redoc@next/bundles/redoc.standalone.js"></script>
<script>
Redoc.init('@Url.Content(Model.Specification)', {
theme: {
colors: {
primary: {
main: '#3f83df'
}
}
},
}, document.getElementById('redoc-container'))
</script>
</body> </body>
</html> </html>

3
src/Squidex/Docs/schemabody.md

@ -1,7 +1,6 @@
The data of the content to be created or updated. The data of the content to be created or updated.
Please note that each field is an object with one entry per language. 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.
When you change the field to be localizable the value will become the value for the master language, depending what the master language is at this point of time.
Read more about it at: https://docs.squidex.io/04-guides/02-api.html Read more about it at: https://docs.squidex.io/04-guides/02-api.html

3
src/Squidex/Pipeline/OpenApi/NSwagHelper.cs

@ -11,7 +11,6 @@ using System.IO;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
using NJsonSchema; using NJsonSchema;
using NSwag; using NSwag;
using Squidex.Web;
namespace Squidex.Pipeline.OpenApi namespace Squidex.Pipeline.OpenApi
{ {
@ -30,7 +29,7 @@ namespace Squidex.Pipeline.OpenApi
} }
} }
public static OpenApiDocument CreateApiDocument(HttpContext context, UrlsOptions urlOptions, string appName) public static OpenApiDocument CreateApiDocument(HttpContext context, string appName)
{ {
var scheme = var scheme =
string.Equals(context.Request.Scheme, "http", StringComparison.OrdinalIgnoreCase) ? string.Equals(context.Request.Scheme, "http", StringComparison.OrdinalIgnoreCase) ?

Loading…
Cancel
Save