Skip to content

Commit

Permalink
fix: missing extractRequestBody field in type
Browse files Browse the repository at this point in the history
  • Loading branch information
js2me committed Sep 20, 2021
1 parent 7d9b393 commit 4b24048
Showing 1 changed file with 15 additions and 40 deletions.
55 changes: 15 additions & 40 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ interface GenerateApiParams {
* extract request params to data contract (Also combine path params and query params into one object)
*/
extractRequestParams?: boolean;
/**
* extract request body type to data contract
*/
extractRequestBody?: boolean;
/**
* prettier configuration
*/
Expand Down Expand Up @@ -131,14 +135,9 @@ export interface Hooks {
/** customize configuration object before sending it to ETA templates */
onPrepareConfig?: <C extends GenerateApiConfiguration>(currentConfiguration: C) => C | void;
/** customize route name as you need */
onCreateRouteName?: (
routeNameInfo: RouteNameInfo,
rawRouteInfo: RawRouteInfo,
) => RouteNameInfo | void;
onCreateRouteName?: (routeNameInfo: RouteNameInfo, rawRouteInfo: RawRouteInfo) => RouteNameInfo | void;
/** customize request params (path params, query params) */
onCreateRequestParams?: (
rawType: SchemaComponent["rawTypeData"],
) => SchemaComponent["rawTypeData"] | void;
onCreateRequestParams?: (rawType: SchemaComponent["rawTypeData"]) => SchemaComponent["rawTypeData"] | void;
/** customize name of model type */
onFormatTypeName?: (typeName: string, rawTypeName?: string) => string | void;
/** customize name of route (operationId), you can do it with using onCreateRouteName too */
Expand Down Expand Up @@ -215,14 +214,10 @@ export interface SchemaComponent {
discriminator?: {
propertyName?: string;
};
$parsed: ParsedSchema<
SchemaTypeObjectContent | SchemaTypeEnumContent | SchemaTypePrimitiveContent
>;
$parsed: ParsedSchema<SchemaTypeObjectContent | SchemaTypeEnumContent | SchemaTypePrimitiveContent>;
};
componentName: string;
typeData: ParsedSchema<
SchemaTypeObjectContent | SchemaTypeEnumContent | SchemaTypePrimitiveContent
> | null;
typeData: ParsedSchema<SchemaTypeObjectContent | SchemaTypeEnumContent | SchemaTypePrimitiveContent> | null;
}

export enum RequestContentKind {
Expand Down Expand Up @@ -346,25 +341,16 @@ export interface GenerateApiConfiguration {
formatDescription: (description: string, inline?: boolean) => string;
internalCase: (value: string) => string;
classNameCase: (value: string) => string;
getInlineParseContent: (
rawTypeData: SchemaComponent["rawTypeData"],
typeName?: string,
) => string;
getInlineParseContent: (rawTypeData: SchemaComponent["rawTypeData"], typeName?: string) => string;
getParseContent: (rawTypeData: SchemaComponent["rawTypeData"], typeName?: string) => ModelType;
getComponentByRef: (ref: string) => SchemaComponent;
parseSchema: (
rawSchema: string | SchemaComponent["rawTypeData"],
typeName?: string,
formattersMap?: Record<MAIN_SCHEMA_TYPES, (content: ModelType) => string>,
) => ModelType;
formatters: Record<
MAIN_SCHEMA_TYPES,
(content: string | object | string[] | object[]) => string
>;
inlineExtraFormatters: Record<
Exclude<MAIN_SCHEMA_TYPES, SCHEMA_TYPES.PRIMITIVE>,
(schema: ModelType) => string
>;
formatters: Record<MAIN_SCHEMA_TYPES, (content: string | object | string[] | object[]) => string>;
inlineExtraFormatters: Record<Exclude<MAIN_SCHEMA_TYPES, SCHEMA_TYPES.PRIMITIVE>, (schema: ModelType) => string>;
formatModelName: (name: string) => string;
fmtToJSDocLine: (line: string, params?: { eol?: boolean }) => string;
_: import("lodash").LoDashStatic;
Expand All @@ -375,12 +361,7 @@ export interface GenerateApiConfiguration {
export interface GenerateApiOutput {
configuration: GenerateApiConfiguration;
files: { name: string; content: string; declaration: { name: string; content: string } | null }[];
createFile: (params: {
path: string;
fileName: string;
content: string;
withPrefix?: boolean;
}) => void;
createFile: (params: { path: string; fileName: string; content: string; withPrefix?: boolean }) => void;
renderTemplate: (
templateContent: string,
data: Record<string, unknown>,
Expand All @@ -390,12 +371,6 @@ export interface GenerateApiOutput {
formatTSContent: (content: string) => string;
}

export declare function generateApi(
params: Omit<GenerateApiParams, "url" | "spec">,
): Promise<GenerateApiOutput>;
export declare function generateApi(
params: Omit<GenerateApiParams, "input" | "spec">,
): Promise<GenerateApiOutput>;
export declare function generateApi(
params: Omit<GenerateApiParams, "input" | "url">,
): Promise<GenerateApiOutput>;
export declare function generateApi(params: Omit<GenerateApiParams, "url" | "spec">): Promise<GenerateApiOutput>;
export declare function generateApi(params: Omit<GenerateApiParams, "input" | "spec">): Promise<GenerateApiOutput>;
export declare function generateApi(params: Omit<GenerateApiParams, "input" | "url">): Promise<GenerateApiOutput>;

0 comments on commit 4b24048

Please sign in to comment.