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

Commit

Permalink
Deal with multiline prop values
Browse files Browse the repository at this point in the history
  • Loading branch information
fabien0102 committed Mar 31, 2021
1 parent 3945ad0 commit db44ed7
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/scripts/import-open-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,12 @@ const importSpecs = (data: string, extension: "yaml" | "json"): Promise<OpenAPIO
* Example:
* reactPropsValueToObjectValue(`{ getConfig("myVar") }`) // `getConfig("myVar")`
*/
export const reactPropsValueToObjectValue = (value: string) => value.replace(/^{(.*)}$/, "$1");
export const reactPropsValueToObjectValue = (value: string) => {
if (value.startsWith("{") && value.endsWith("}")) {
return value.slice(1, -1);
}
return value;
};

/**
* Generate a restful-react component from openapi operation specs
Expand Down

0 comments on commit db44ed7

Please sign in to comment.