From c7b13b43fcc572801efaed37900ece62643e4a08 Mon Sep 17 00:00:00 2001 From: Lubos Date: Sat, 3 Jan 2026 00:15:16 +0800 Subject: [PATCH] docs: fix formatting on sdk plugin page --- dev/openapi-ts.config.ts | 68 +++++++++++++++++----------------- docs/openapi-ts/plugins/sdk.md | 21 ++++++----- 2 files changed, 46 insertions(+), 43 deletions(-) diff --git a/dev/openapi-ts.config.ts b/dev/openapi-ts.config.ts index 5f9e8c0c6..c366f5414 100644 --- a/dev/openapi-ts.config.ts +++ b/dev/openapi-ts.config.ts @@ -46,40 +46,40 @@ export default defineConfig(() => { // openapi: '3.1.0', // paths: {}, // }, - // path: path.resolve( - // getSpecsPath(), - // // '2.0.x', - // // '3.0.x', - // '3.1.x', - // // 'circular.yaml', - // // 'dutchie.json', - // // 'enum-names-values.yaml', - // 'full.yaml', - // // 'integer-formats.yaml', - // // 'invalid', - // // 'object-property-names.yaml', - // // 'openai.yaml', - // // 'opencode.yaml', - // // 'pagination-ref.yaml', - // // 'schema-const.yaml', - // // 'sdk-instance.yaml', - // // 'sdk-method-class-conflict.yaml', - // // 'sdk-nested-classes.yaml', - // // 'sdk-nested-conflict.yaml', - // // 'string-with-format.yaml', - // // 'transformers.json', - // // 'transformers-recursive.json', - // // 'type-format.yaml', - // // 'validators.yaml', - // // 'validators-circular-ref.json', - // // 'validators-circular-ref-2.yaml', - // // 'zoom-video-sdk.json', - // ), + path: path.resolve( + getSpecsPath(), + // '2.0.x', + // '3.0.x', + '3.1.x', + // 'circular.yaml', + // 'dutchie.json', + // 'enum-names-values.yaml', + // 'full.yaml', + // 'integer-formats.yaml', + // 'invalid', + // 'object-property-names.yaml', + // 'openai.yaml', + 'opencode.yaml', + // 'pagination-ref.yaml', + // 'schema-const.yaml', + // 'sdk-instance.yaml', + // 'sdk-method-class-conflict.yaml', + // 'sdk-nested-classes.yaml', + // 'sdk-nested-conflict.yaml', + // 'string-with-format.yaml', + // 'transformers.json', + // 'transformers-recursive.json', + // 'type-format.yaml', + // 'validators.yaml', + // 'validators-circular-ref.json', + // 'validators-circular-ref-2.yaml', + // 'zoom-video-sdk.json', + ), // path: 'https://get.heyapi.dev/hey-api/backend?branch=main&version=1.0.0', // path: 'http://localhost:4000/', // path: 'http://localhost:8000/openapi.json', // path: 'https://mongodb-mms-prod-build-server.s3.amazonaws.com/openapi/2caffd88277a4e27c95dcefc7e3b6a63a3b03297-v2-2023-11-15.json', - path: 'https://raw.githubusercontent.com/swagger-api/swagger-petstore/master/src/main/resources/openapi.yaml', + // path: 'https://raw.githubusercontent.com/swagger-api/swagger-petstore/master/src/main/resources/openapi.yaml', // watch: { // enabled: true, // interval: 500, @@ -290,7 +290,7 @@ export default defineConfig(() => { // }, }, { - // auth: false, + auth: false, // client: false, // getSignature: ({ fields, signature, operation }) => { // // ... @@ -304,7 +304,7 @@ export default defineConfig(() => { // // casing: 'snake_case', // name: 'OpencodeClient', // }, - containerName: 'PetStore', + containerName: 'OpencodeClient', // nesting(operation) { // if (operation.path === '/pet/{petId}' || operation.path === '/pet') { // return ['pet', operation.operationId?.replace(/Pet/, '') || operation.method.toLocaleLowerCase()]; @@ -318,7 +318,7 @@ export default defineConfig(() => { // methods: 'static', // nesting: 'id', // segmentName: '{{name}}Seggy', - // strategy: 'single', + strategy: 'single', // strategy(operation) { // const locations = OperationStrategy.byTags({ // fallback: 'default', @@ -335,7 +335,7 @@ export default defineConfig(() => { // }, // strategyDefaultTag: 'DaxLikedThis', }, - // paramsStructure: 'flat', + paramsStructure: 'flat', // responseStyle: 'data', // signature: 'auto', // signature: 'client', diff --git a/docs/openapi-ts/plugins/sdk.md b/docs/openapi-ts/plugins/sdk.md index 5c2a7cebf..18f80c456 100644 --- a/docs/openapi-ts/plugins/sdk.md +++ b/docs/openapi-ts/plugins/sdk.md @@ -109,15 +109,16 @@ As shown above, by default our SDK class is called `Sdk`. The first thing you'll ::: code-group + ```ts [example] import { client } from './client.gen'; import type { AddPetData, AddPetErrors, AddPetResponses } from './types.gen'; -export class PetStore extends HeyApiClient { - // [!code ++] +export class PetStore extends HeyApiClient { // [!code ++] /** ... */ } ``` + ```js [config] export default { @@ -148,25 +149,24 @@ To demonstrate the power of this feature, let's nest a few endpoints inside a `P ::: code-group + ```ts [example] import { client } from './client.gen'; import type { AddPetData, AddPetErrors, AddPetResponses } from './types.gen'; export class Pet extends HeyApiClient { - public add(options: Options) { - // [!code ++] + public add(options: Options) { // [!code ++] /** ... */ } } export class PetStore extends HeyApiClient { - get pet(): Pet { - // [!code ++] + get pet(): Pet { // [!code ++] /** ... */ } } ``` - + ```js [config] export default { @@ -239,17 +239,20 @@ For a more granular approach, manually add a validator plugin and set `validator ::: code-group + ```ts [example] import * as v from 'valibot'; export const addPet = (options: Options) => (options.client ?? client).post({ - requestValidator: async (data) => await v.parseAsync(vAddPetData, data), // [!code ++] - responseValidator: async (data) => + requestValidator: async (data) => // [!code ++] + await v.parseAsync(vAddPetData, data), // [!code ++] + responseValidator: async (data) => // [!code ++] await v.parseAsync(vAddPetResponse, data), // [!code ++] /** ... */ }); ``` + ```js [config] export default { -- 2.51.2