Skip to content
This repository has been archived by the owner on Nov 11, 2023. It is now read-only.

Commit

Permalink
Add docs to query params
Browse files Browse the repository at this point in the history
  • Loading branch information
fabien0102 committed Jan 9, 2020
1 parent 45d0ef6 commit 396eeac
Show file tree
Hide file tree
Showing 3 changed files with 434 additions and 403 deletions.
10 changes: 7 additions & 3 deletions src/scripts/import-open-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -337,9 +337,11 @@ export const generateRestfulComponent = (
const queryParamsType = queryParams
.map(p => {
const processedName = IdentifierRegexp.test(p.name) ? p.name : `"${p.name}"`;
return `${processedName}${p.required ? "" : "?"}: ${resolveValue(p.schema!)}`;
return `${formatDescription(p.description, 2)}${processedName}${p.required ? "" : "?"}: ${resolveValue(
p.schema!,
)}`;
})
.join("; ");
.join(";\n ");

const genericsTypes =
verb === "get"
Expand Down Expand Up @@ -372,7 +374,9 @@ export ${
}${
queryParamsType
? `
export interface ${componentName}QueryParams {${queryParamsType}}
export interface ${componentName}QueryParams {
${queryParamsType};
}
`
: ""
}
Expand Down
11 changes: 10 additions & 1 deletion src/scripts/tests/__snapshots__/import-open-api.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,16 @@ export interface Error {
message: string;
}
export interface FindPetsQueryParams {tags?: string[]; limit?: number}
export interface FindPetsQueryParams {
/**
* tags to filter by
*/
tags?: string[];
/**
* maximum number of results to return
*/
limit?: number;
}
export type FindPetsProps = Omit<GetProps<Pet[], Error, FindPetsQueryParams>, \\"path\\">;
Expand Down
Loading

0 comments on commit 396eeac

Please sign in to comment.