Basically working svelte interaction with orchard
This commit is contained in:
13
src/OAP/Oap.Api/Manifest.cs
Normal file
13
src/OAP/Oap.Api/Manifest.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using OrchardCore.Modules.Manifest;
|
||||
|
||||
[assembly: Module(
|
||||
Name = "Overseas Auto Protection API",
|
||||
Author = "Overseas Auto Protection",
|
||||
Website = "https://oaprotection.org/api/",
|
||||
Version = "0.0.1",
|
||||
Description = "API for OAP services",
|
||||
Category = "Content Management",
|
||||
Dependencies = [
|
||||
"OAP.Content"
|
||||
]
|
||||
)]
|
||||
23
src/OAP/Oap.Api/Oap.Api.csproj
Normal file
23
src/OAP/Oap.Api/Oap.Api.csproj
Normal file
@@ -0,0 +1,23 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<InvariantGlobalization>true</InvariantGlobalization>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Facility.AspNetCore" Version="3.9.0" />
|
||||
<PackageReference Include="Facility.Core" Version="2.27.0" />
|
||||
<PackageReference Include="OrchardCore.Module.Targets" Version="1.8.2" />
|
||||
<PackageReference Include="OrchardCore.DisplayManagement" Version="1.8.2" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Oap.Api.v1\Oap.Api.v1.csproj" />
|
||||
<ProjectReference Include="..\Oap\Oap.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
48
src/OAP/Oap.Api/OapApiV1.cs
Normal file
48
src/OAP/Oap.Api/OapApiV1.cs
Normal file
@@ -0,0 +1,48 @@
|
||||
using Facility.Core;
|
||||
using Oap.Api.v1;
|
||||
|
||||
namespace Oap.Api;
|
||||
|
||||
public sealed class OapApiV1 : IOapApiV1
|
||||
{
|
||||
public OapApiV1()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public Task<ServiceResult<CreateApplicationResponseDto>> CreateApplicationAsync(CreateApplicationRequestDto request, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return Task.FromResult(ServiceResult.Success(new CreateApplicationResponseDto
|
||||
{
|
||||
Application = new ApplicationDto
|
||||
{
|
||||
Id = "-1",
|
||||
Status = ApplicationStatus.InProgress,
|
||||
Terms = new ApplicationTermsDto
|
||||
{
|
||||
HasReadInstructions = request.ApplicationCreateSet.Terms.HasReadInstructions,
|
||||
}
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
public Task<ServiceResult<GetApplicationResponseDto>> GetApplicationAsync(GetApplicationRequestDto request, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return Task.FromResult(ServiceResult.Success(new GetApplicationResponseDto
|
||||
{
|
||||
Application = new ApplicationDto
|
||||
{
|
||||
Id = "1",
|
||||
Status = ApplicationStatus.InProgress,
|
||||
Terms = new ApplicationTermsDto
|
||||
{
|
||||
HasReadInstructions = true,
|
||||
}
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
public Task<ServiceResult<GetApplicationsResponseDto>> GetApplicationsAsync(GetApplicationsRequestDto request, CancellationToken cancellationToken = default) => throw new NotImplementedException();
|
||||
|
||||
public Task<ServiceResult<UpdateApplicationResponseDto>> UpdateApplicationAsync(UpdateApplicationRequestDto request, CancellationToken cancellationToken = default) => throw new NotImplementedException();
|
||||
}
|
||||
33
src/OAP/Oap.Api/Startup.cs
Normal file
33
src/OAP/Oap.Api/Startup.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using Facility.AspNetCore;
|
||||
using Facility.Core.Http;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Routing;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Oap.Api.v1;
|
||||
using Oap.Api.v1.Http;
|
||||
|
||||
namespace Oap.Api;
|
||||
|
||||
public class Startup : OrchardCore.Modules.StartupBase
|
||||
{
|
||||
public override void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
services.AddScoped<IOapApiV1, OapApiV1>();
|
||||
|
||||
services.AddScoped(sp =>
|
||||
{
|
||||
return new OapApiV1HttpHandler(
|
||||
sp.GetRequiredService<IOapApiV1>(),
|
||||
new ServiceHttpHandlerSettings
|
||||
{
|
||||
RootPath = "/oap/api/v1",
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
public override void Configure(IApplicationBuilder builder, IEndpointRouteBuilder routes, IServiceProvider serviceProvider)
|
||||
{
|
||||
builder.UseFacilityExceptionHandler();
|
||||
builder.UseFacilityHttpHandler<OapApiV1HttpHandler>();
|
||||
}
|
||||
}
|
||||
248
src/OAP/Oap.Api/swagger.json
Normal file
248
src/OAP/Oap.Api/swagger.json
Normal file
@@ -0,0 +1,248 @@
|
||||
{
|
||||
"swagger": "2.0",
|
||||
"info": {
|
||||
"title": "OapApiV1",
|
||||
"description": "API providing OAP functionality for the application form, calculator and more.\n\n## Heading\n\nUse a primary heading to indicate the member name.",
|
||||
"version": "0.0.0",
|
||||
"x-identifier": "OapApiV1",
|
||||
"x-codegen": "DO NOT EDIT: generated by fsdgenswagger"
|
||||
},
|
||||
"host": "oaprotection.org",
|
||||
"basePath": "/api/v1",
|
||||
"schemes": [
|
||||
"https"
|
||||
],
|
||||
"paths": {
|
||||
"/applications": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"bob"
|
||||
],
|
||||
"summary": "Gets applications for the current user.",
|
||||
"description": "Gets the current user's applications in pages.",
|
||||
"operationId": "getApplications",
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"parameters": [
|
||||
{
|
||||
"in": "query",
|
||||
"name": "status",
|
||||
"description": "Filter applications by the given status.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"InProgress",
|
||||
"Submitted"
|
||||
]
|
||||
},
|
||||
{
|
||||
"in": "query",
|
||||
"name": "limit",
|
||||
"description": "The limit of returned results.",
|
||||
"type": "integer",
|
||||
"format": "int32"
|
||||
},
|
||||
{
|
||||
"in": "query",
|
||||
"name": "nextToken",
|
||||
"description": "The token presenting the next page of applications to get.",
|
||||
"type": "string"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/GetApplicationsResponse"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/applications/": {
|
||||
"post": {
|
||||
"summary": "Creates a new application for the current user.",
|
||||
"description": "Creates a new application for the current user.",
|
||||
"operationId": "createApplication",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"parameters": [
|
||||
{
|
||||
"in": "body",
|
||||
"name": "request",
|
||||
"description": "The application to create.",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/ApplicationCreateSet"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "The created application.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/Application"
|
||||
},
|
||||
"x-identifier": "application"
|
||||
},
|
||||
"201": {
|
||||
"description": ""
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/applications/{id}": {
|
||||
"get": {
|
||||
"summary": "Gets the specified application for the current user.",
|
||||
"operationId": "getApplication",
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"parameters": [
|
||||
{
|
||||
"in": "path",
|
||||
"name": "id",
|
||||
"description": "The widget ID.",
|
||||
"required": true,
|
||||
"type": "string"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "The requested widget.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/Application"
|
||||
},
|
||||
"x-identifier": "application"
|
||||
},
|
||||
"304": {
|
||||
"description": "",
|
||||
"x-identifier": "notModified"
|
||||
}
|
||||
}
|
||||
},
|
||||
"patch": {
|
||||
"summary": "Updates the application.",
|
||||
"description": "Updates an application for the current user, given the ID of the application to update.",
|
||||
"operationId": "updateApplication",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"parameters": [
|
||||
{
|
||||
"in": "path",
|
||||
"name": "id",
|
||||
"description": "The application ID.",
|
||||
"required": true,
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"in": "body",
|
||||
"name": "request",
|
||||
"description": "The application update set.",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/ApplicationChangeSet"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "The updated Application.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/Application"
|
||||
},
|
||||
"x-identifier": "application"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"definitions": {
|
||||
"GetApplicationsResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"applications": {
|
||||
"description": "The applications.",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/Application"
|
||||
}
|
||||
},
|
||||
"total": {
|
||||
"description": "The total number of applications.",
|
||||
"type": "integer",
|
||||
"format": "int64"
|
||||
},
|
||||
"nextToken": {
|
||||
"description": "The token representing the next page of results.",
|
||||
"type": "string"
|
||||
},
|
||||
"isLastPage": {
|
||||
"description": "True if this is the last page of results, false otherwise.",
|
||||
"type": "boolean"
|
||||
}
|
||||
}
|
||||
},
|
||||
"ApplicationCreateSet": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"terms": {
|
||||
"$ref": "#/definitions/ApplicationTermsCreateSet"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Application": {
|
||||
"description": "An application.",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"id": {
|
||||
"description": "A unique identifier for the application.",
|
||||
"type": "string"
|
||||
},
|
||||
"status": {
|
||||
"description": "The current status of this application.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"InProgress",
|
||||
"Submitted"
|
||||
]
|
||||
},
|
||||
"terms": {
|
||||
"$ref": "#/definitions/ApplicationTerms"
|
||||
}
|
||||
},
|
||||
"x-remarks": "Represents a user's application, whether in progress or submitted."
|
||||
},
|
||||
"ApplicationChangeSet": {
|
||||
"type": "object",
|
||||
"properties": {}
|
||||
},
|
||||
"ApplicationTermsCreateSet": {
|
||||
"required": [
|
||||
"hasReadInstructions"
|
||||
],
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"hasReadInstructions": {
|
||||
"type": "boolean"
|
||||
}
|
||||
}
|
||||
},
|
||||
"ApplicationTerms": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"hasReadInstructions": {
|
||||
"type": "boolean"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user