mirror of
https://github.com/fluxerapp/fluxer.git
synced 2026-12-02 23:22:46 -08:00
refactor(packages): flatten branches and keep helpers private
This commit is contained in:
7 files changed
+45
-31
No files matched your search
@@ -88,11 +88,14 @@ function toPascalCase(value: string): string {
|
||||
function branchNamePrefix(discriminator: core.JSONSchema._JSONSchema | undefined): string | undefined {
|
||||
if (typeof discriminator !== 'object') return undefined;
|
||||
const enumNames = discriminator['x-enumNames'];
|
||||
const value = Array.isArray(enumNames)
|
||||
? enumNames[0]
|
||||
: discriminator.enum?.length === 1
|
||||
? discriminator.enum[0]
|
||||
: discriminator.const;
|
||||
let value: unknown;
|
||||
if (Array.isArray(enumNames)) {
|
||||
value = enumNames[0];
|
||||
} else if (discriminator.enum?.length === 1) {
|
||||
value = discriminator.enum[0];
|
||||
} else {
|
||||
value = discriminator.const;
|
||||
}
|
||||
return typeof value === 'string' ? toPascalCase(value) : undefined;
|
||||
}
|
||||
|
||||
|
||||
@@ -156,7 +156,12 @@ export class OpenAPIOperationBuilder {
|
||||
}
|
||||
const required = new Set(schema.required ?? []);
|
||||
for (const [name, property] of Object.entries(schema.properties)) {
|
||||
const propertySchema: OpenAPISchema = typeof property === 'boolean' ? (property ? {} : {not: {}}) : property;
|
||||
let propertySchema: OpenAPISchema;
|
||||
if (typeof property === 'boolean') {
|
||||
propertySchema = property ? {} : {not: {}};
|
||||
} else {
|
||||
propertySchema = property;
|
||||
}
|
||||
const key = `${location}:${name}`;
|
||||
if (parameters.has(key)) throw new Error(`Duplicate parameter ${key} for ${route.method} ${route.path}`);
|
||||
parameters.set(key, {
|
||||
|
||||
Reference in new issue
Block a user