Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 2 additions & 19 deletions templates/UmbracoExtension/.template.config/template.json
Original file line number Diff line number Diff line change
Expand Up @@ -136,22 +136,6 @@
],
"actionId": "210D431B-A78B-4D2F-B762-4ED3E3EA9025",
"continueOnError": true
},
{
"actionId": "3A7C4B45-1F5D-4A30-959A-51B88E82B5D2",
"args": {
"executable": "powershell",
"args": "cd Client;npm install;npm run build;",
"redirectStandardError": false,
"redirectStandardOutput": false
},
"manualInstructions": [
{
"text": "From the 'Client' folder run 'npm install' and then 'npm run build'"
}
],
"continueOnError": true,
"description ": "Installs node modules"
}
],
"sources": [
Expand All @@ -160,11 +144,10 @@
{
"condition": "(!IncludeExample)",
"exclude": [
"[Cc]lient/src/dashboards/**",
"[Cc]lient/src/api/schemas.gen.ts"
"[Cc]lient/src/dashboards/**"
]
}
]
}
]
}
}
12 changes: 6 additions & 6 deletions templates/UmbracoExtension/Client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
"generate-client": "node scripts/generate-openapi.js https://localhost:44339/umbraco/swagger/umbracoextension/swagger.json"
},
"devDependencies": {
"@hey-api/client-fetch": "^0.4.2",
"@hey-api/openapi-ts": "^0.53.11",
"@hey-api/client-fetch": "^0.8.3",
"@hey-api/openapi-ts": "^0.64.10",
"@umbraco-cms/backoffice": "^UMBRACO_VERSION_FROM_TEMPLATE",
"chalk": "^5.3.0",
"chalk": "^5.4.1",
"cross-env": "^7.0.3",
"node-fetch": "^3.3.2",
"typescript": "^5.6.3",
"vite": "^5.4.9"
"typescript": "^5.8.2",
"vite": "^6.2.0"
}
}
}
4 changes: 2 additions & 2 deletions templates/UmbracoExtension/Client/public/umbraco-package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"id": "Umbraco.Extension",
"name": "Umbraco.Extension",
"version": "0.0.0",
"allowPackageTelemetry": true,
"allowTelemetry": true,
"extensions": [
{
"name": "Umbraco ExtensionBundle",
Expand All @@ -11,4 +11,4 @@
"js": "/App_Plugins/UmbracoExtension/umbraco-extension.js"
}
]
}
}
22 changes: 15 additions & 7 deletions templates/UmbracoExtension/Client/scripts/generate-openapi.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import fetch from 'node-fetch';
import chalk from 'chalk';
import { createClient } from '@hey-api/openapi-ts';
import { createClient, defaultPlugins } from '@hey-api/openapi-ts';

// Start notifying user we are generating the TypeScript client
console.log(chalk.green("Generating OpenAPI client..."));
Expand All @@ -20,7 +20,7 @@ process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
console.log("Ensure your Umbraco instance is running");
console.log(`Fetching OpenAPI definition from ${chalk.yellow(swaggerUrl)}`);

fetch(swaggerUrl).then(response => {
fetch(swaggerUrl).then(async (response) => {
if (!response.ok) {
console.error(chalk.red(`ERROR: OpenAPI spec returned with a non OK (200) response: ${response.status} ${response.statusText}`));
console.error(`The URL to your Umbraco instance may be wrong or the instance is not running`);
Expand All @@ -31,13 +31,21 @@ fetch(swaggerUrl).then(response => {
console.log(`OpenAPI spec fetched successfully`);
console.log(`Calling ${chalk.yellow('hey-api')} to generate TypeScript client`);

createClient({
client: '@hey-api/client-fetch',
await createClient({
input: swaggerUrl,
output: 'src/api',
services: {
asClass: true,
}
plugins: [
...defaultPlugins,
'@hey-api/client-fetch',
{
name: '@hey-api/typescript',
enums: 'typescript'
},
{
name: '@hey-api/sdk',
asClass: true
}
],
});

})
Expand Down
18 changes: 18 additions & 0 deletions templates/UmbracoExtension/Client/src/api/client.gen.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// This file is auto-generated by @hey-api/openapi-ts

import type { ClientOptions } from './types.gen';
import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from '@hey-api/client-fetch';

/**
* The `createClientConfig()` function will be called on client initialization
* and the returned object will become the client's initial configuration.
*
* You may want to initialize your client this way instead of calling
* `setConfig()`. This is useful for example if you're using Next.js
* to ensure your client always has the correct values.
*/
export type CreateClientConfig<T extends DefaultClientOptions = ClientOptions> = (override?: Config<DefaultClientOptions & T>) => Config<Required<DefaultClientOptions> & T>;

export const client = createClient(createConfig<ClientOptions>({
baseUrl: 'https://localhost:44389'
}));
5 changes: 1 addition & 4 deletions templates/UmbracoExtension/Client/src/api/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// This file is auto-generated by @hey-api/openapi-ts
//#if(IncludeExample)
export * from './schemas.gen';
//#endif
export * from './services.gen';
export * from './types.gen';
export * from './sdk.gen';
Loading