feat(openapi): integrate openapi directly into the repo.

This commit is contained in:
Philipp Kunz 2024-06-15 16:21:45 +02:00
parent 5c0e4c6b90
commit d90be18e74
6 changed files with 25305 additions and 25 deletions

View File

@ -12,7 +12,7 @@
"test": "(tstest test/ --web)", "test": "(tstest test/ --web)",
"build": "(tsbuild --web --allowimplicitany)", "build": "(tsbuild --web --allowimplicitany)",
"buildDocs": "(tsdoc)", "buildDocs": "(tsdoc)",
"updateAPI": "openapi-typescript https://docs.hetzner.cloud/spec.json --output ts/api.ts && tsc" "updateAPI": "openapi-typescript https://docs.hetzner.cloud/spec.json --output ts/openapi.spec.ts"
}, },
"devDependencies": { "devDependencies": {
"@git.zone/tsbuild": "^2.1.25", "@git.zone/tsbuild": "^2.1.25",

View File

@ -36,7 +36,7 @@ const testserver = tap.test('should be able to create a server', async (toolsArg
tap.test('should be able to delete a server', async () => { tap.test('should be able to delete a server', async () => {
const testServer: hetznercloud.HetznerServer = const testServer: hetznercloud.HetznerServer =
await (testserver.testResultPromise as Promise<hetznercloud.HetznerServer>); await (testserver.testResultPromise as Promise<hetznercloud.HetznerServer>);
// await testServer.delete(); await testServer.delete();
}); });
tap.start(); tap.start();

View File

@ -3,6 +3,6 @@
*/ */
export const commitinfo = { export const commitinfo = {
name: '@apiclient.xyz/hetznercloud', name: '@apiclient.xyz/hetznercloud',
version: '1.1.1', version: '1.2.0',
description: 'An unofficial TypeScript API client for the Hetzner Cloud API providing easy methods to manage servers, volumes, and firewalls.' description: 'An unofficial TypeScript API client for the Hetzner Cloud API providing easy methods to manage servers, volumes, and firewalls.'
} }

View File

@ -1,9 +1,3 @@
import * as hetznerOpenapi from '@tempfix/hetzner-openapi';
export {
hetznerOpenapi
}
// @push.rocks // @push.rocks
import * as smartrequest from '@push.rocks/smartrequest'; import * as smartrequest from '@push.rocks/smartrequest';

25285
ts/openapi.spec.ts Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,15 +1,16 @@
import * as plugins from './hetznercloud.plugins.js'; import * as plugins from './hetznercloud.plugins.js';
import * as hetznerOpenapiSpec from './openapi.spec.js';
// datacenters // datacenters
export type TDatacenters = plugins.hetznerOpenapi.paths['/datacenters']['get']['responses']['200']['content']['application/json']; export type TDatacenters = hetznerOpenapiSpec.paths['/datacenters']['get']['responses']['200']['content']['application/json'];
// servers // servers
export type IServer = plugins.hetznerOpenapi.paths['/servers/{id}']['get']['responses']['200']['content']['application/json']['server']; export type IServer = hetznerOpenapiSpec.paths['/servers/{id}']['get']['responses']['200']['content']['application/json']['server'];
export type TServersGetRequestBody = {}; export type TServersGetRequestBody = {};
export type TServersGetResponseBody = plugins.hetznerOpenapi.paths['/servers']['get']['responses']['200']['content']['application/json']; export type TServersGetResponseBody = hetznerOpenapiSpec.paths['/servers']['get']['responses']['200']['content']['application/json'];
export type TServerCreateRequestBody = plugins.hetznerOpenapi.paths['/servers']['post']['requestBody']['content']['application/json']; export type TServerCreateRequestBody = hetznerOpenapiSpec.paths['/servers']['post']['requestBody']['content']['application/json'];
export type TServerCreateResponseBody = plugins.hetznerOpenapi.paths['/servers']['post']['responses']['201']['content']['application/json']; export type TServerCreateResponseBody = hetznerOpenapiSpec.paths['/servers']['post']['responses']['201']['content']['application/json'];
export type TServerDeleteRequestBody = plugins.hetznerOpenapi.paths['/servers/{id}']['delete']; export type TServerDeleteRequestBody = hetznerOpenapiSpec.paths['/servers/{id}']['delete'];
// server types // server types
export type THetznerCloudServerName = export type THetznerCloudServerName =
@ -43,17 +44,17 @@ export type THetznerCloudServerName =
export type THetznerCloudLocationName = 'fsn1' | 'nbg1' | 'hel1' | 'ash' | 'hil'; export type THetznerCloudLocationName = 'fsn1' | 'nbg1' | 'hel1' | 'ash' | 'hil';
// volumes // volumes
export type IVolume = plugins.hetznerOpenapi.paths['/volumes/{id}']['get']['responses']['200']['content']['application/json']['volume']; export type IVolume = hetznerOpenapiSpec.paths['/volumes/{id}']['get']['responses']['200']['content']['application/json']['volume'];
export type TVolumeGetRequestBody = {}; export type TVolumeGetRequestBody = {};
export type TVolumeGetResponseBody = plugins.hetznerOpenapi.paths['/volumes']['get']['responses']['200']['content']['application/json']; export type TVolumeGetResponseBody = hetznerOpenapiSpec.paths['/volumes']['get']['responses']['200']['content']['application/json'];
export type TVolumeCreateRequestBody = plugins.hetznerOpenapi.paths['/volumes']['post']['requestBody']['content']['application/json']; export type TVolumeCreateRequestBody = hetznerOpenapiSpec.paths['/volumes']['post']['requestBody']['content']['application/json'];
export type TVolumeCreateResponseBody = plugins.hetznerOpenapi.paths['/volumes']['post']['responses']['201']['content']['application/json']; export type TVolumeCreateResponseBody = hetznerOpenapiSpec.paths['/volumes']['post']['responses']['201']['content']['application/json'];
export type TVolumeDeleteRequestBody = plugins.hetznerOpenapi.paths['/volumes/{id}']['delete']; export type TVolumeDeleteRequestBody = hetznerOpenapiSpec.paths['/volumes/{id}']['delete'];
// firewalls // firewalls
export type IFirewall = plugins.hetznerOpenapi.paths['/firewalls/{id}']['get']['responses']['200']['content']['application/json']['firewall']; export type IFirewall = hetznerOpenapiSpec.paths['/firewalls/{id}']['get']['responses']['200']['content']['application/json']['firewall'];
export type TFirewallsGetRequestBody = {}; export type TFirewallsGetRequestBody = {};
export type TFirewallsGetResponseBody = plugins.hetznerOpenapi.paths['/firewalls']['get']['responses']['200']['content']['application/json']; export type TFirewallsGetResponseBody = hetznerOpenapiSpec.paths['/firewalls']['get']['responses']['200']['content']['application/json'];
export type TFirewallCreateRequestBody = plugins.hetznerOpenapi.paths['/firewalls']['post']['requestBody']['content']['application/json']; export type TFirewallCreateRequestBody = hetznerOpenapiSpec.paths['/firewalls']['post']['requestBody']['content']['application/json'];
export type TFirewallCreateResponseBody = plugins.hetznerOpenapi.paths['/firewalls']['post']['responses']['201']['content']['application/json']; export type TFirewallCreateResponseBody = hetznerOpenapiSpec.paths['/firewalls']['post']['responses']['201']['content']['application/json'];
export type TFirewallDeleteRequestBody = plugins.hetznerOpenapi.paths['/firewalls/{id}']['delete']; export type TFirewallDeleteRequestBody = hetznerOpenapiSpec.paths['/firewalls/{id}']['delete'];