Files
signoz/frontend/orval.config.ts
Ashwin Bhatkal 4117c7442b
Some checks failed
build-staging / prepare (push) Has been cancelled
build-staging / js-build (push) Has been cancelled
build-staging / go-build (push) Has been cancelled
build-staging / staging (push) Has been cancelled
Release Drafter / update_release_draft (push) Has been cancelled
feature: init open api ts code gen (#10011)
* feature: init open api ts code gen

* chore: update custom instance to a separate axios instance

* chore: update code owners

* chore: set up node version in CI

* fix: node version

* chore: update jsci.yaml

* chore: update goci.yaml

* chore: rename instance

* chore: resolve comments
2026-01-22 15:22:56 +05:30

98 lines
2.3 KiB
TypeScript

/**
* When making changes to this file, remove this the file name from .eslintignore and tsconfig.json
* The reason this is required because of the moduleResolution being "node". Changing this is a more detailed effort.
* So, until then, we will keep this file ignored for eslint and typescript.
*/
import { defineConfig } from 'orval';
export default defineConfig({
signoz: {
input: {
target: '../docs/api/openapi.yml',
},
output: {
target: './src/api/generated/services',
client: 'react-query',
httpClient: 'axios',
mode: 'tags-split',
prettier: true,
headers: true,
clean: true,
override: {
query: {
useQuery: true,
useMutation: true,
useInvalidate: true,
signal: true,
useOperationIdAsQueryKey: true,
},
useDates: true,
useNamedParameters: true,
enumGenerationType: 'enum',
mutator: {
path: './src/api/index.ts',
name: 'GeneratedAPIInstance',
},
jsDoc: {
filter: (schema) => {
const allowlist = [
'type',
'format',
'maxLength',
'minLength',
'description',
'minimum',
'maximum',
'exclusiveMinimum',
'exclusiveMaximum',
'pattern',
'nullable',
'enum',
];
return Object.entries(schema || {})
.filter(([key]) => allowlist.includes(key))
.map(([key, value]: [string, any]) => ({
key,
value,
}))
.sort((a, b) => a.key.length - b.key.length);
},
},
components: {
schemas: {
suffix: 'DTO',
},
responses: {
suffix: 'Response',
},
parameters: {
suffix: 'Params',
},
requestBodies: {
suffix: 'Body',
},
},
// info is of type InfoObject from openapi spec
header: (info: { title: string; version: string }): string[] => [
`! Do not edit manually`,
`* The file has been auto-generated using Orval for SigNoz`,
`* regenerate with 'yarn generate:api'`,
...(info.title ? [info.title] : []),
...(info.version ? [`OpenAPI spec version: ${info.version}`] : []),
],
// @ts-expect-error
// propertySortOrder, urlEncodeParameters, aliasCombinedTypes
// are valid options in the document without types
propertySortOrder: 'Alphabetical',
urlEncodeParameters: true,
aliasCombinedTypes: true,
},
},
},
});