move version to its own endpoint

This commit is contained in:
Jacob Overgaard
2022-05-19 10:38:02 +02:00
parent 4bde7bf86b
commit 64fe70d9f9
5 changed files with 73 additions and 8 deletions

View File

@@ -19,6 +19,22 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
/version:
get:
operationId: GetVersion
responses:
'200':
description: 200 response
content:
application/json:
schema:
$ref: '#/components/schemas/VersionResponse'
default:
description: default response
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
/user/login:
post:
operationId: PostUserLogin
@@ -99,12 +115,9 @@ components:
InitResponse:
type: object
properties:
version:
type: string
installed:
type: boolean
required:
- version
- installed
ErrorResponse:
type: object
@@ -113,6 +126,13 @@ components:
type: string
required:
- errorMessage
VersionResponse:
type: object
properties:
version:
type: string
required:
- version
UserLoginRequest:
type: object
properties:

View File

@@ -7,6 +7,9 @@ export interface paths {
"/init": {
get: operations["GetInit"];
};
"/version": {
get: operations["GetVersion"];
};
"/user/login": {
post: operations["PostUserLogin"];
};
@@ -25,12 +28,14 @@ export interface paths {
export interface components {
schemas: {
InitResponse: {
version: string;
installed: boolean;
};
ErrorResponse: {
errorMessage: string;
};
VersionResponse: {
version: string;
};
UserLoginRequest: {
username: string;
password: string;
@@ -106,6 +111,22 @@ export interface operations {
};
};
};
GetVersion: {
responses: {
/** 200 response */
200: {
content: {
"application/json": components["schemas"]["VersionResponse"];
};
};
/** default response */
default: {
content: {
"application/json": components["schemas"]["ErrorResponse"];
};
};
};
};
PostUserLogin: {
parameters: {};
responses: {

View File

@@ -8,9 +8,18 @@ export const handlers = [
// Respond with a 200 status code
ctx.status(200),
ctx.json({
version: '13.0.0',
installed: import.meta.env.VITE_UMBRACO_INSTALL_STATUS !== 'false',
})
} as components['schemas']['InitResponse']),
);
}),
rest.get('/umbraco/backoffice/version', (_req, res, ctx) => {
return res(
// Respond with a 200 status code
ctx.status(200),
ctx.json({
version: '13.0.0'
} as components['schemas']['VersionResponse']),
);
}),

View File

@@ -2,7 +2,7 @@ import './installer';
import { api, body, defaultResponse, endpoint, request, response } from '@airtasker/spot';
import { ErrorResponse, InitResponse, UserLoginRequest, UserResponse } from './models';
import { ErrorResponse, InitResponse, UserLoginRequest, UserResponse, VersionResponse } from './models';
/* eslint-disable */
@api({ name: "umbraco-backoffice-api", version: "1.0.0" })
@@ -20,6 +20,18 @@ class GetInit {
default(@body body: ErrorResponse) { }
}
@endpoint({
method: "GET",
path: "/version",
})
class GetVersion {
@response({ status: 200 })
success(@body body: VersionResponse) { }
@defaultResponse
default(@body body: ErrorResponse) { }
}
@endpoint({
method: "POST",
path: "/user/login",

View File

@@ -1,8 +1,11 @@
export interface InitResponse {
version: string;
installed: boolean;
}
export interface VersionResponse {
version: string;
}
export interface UserResponse {
username: string;
role: string;