Skip to content

Commit

Permalink
fix(zod): handling correctly deeper ref by deferencing
Browse files Browse the repository at this point in the history
  • Loading branch information
anymaniax committed Apr 4, 2023
1 parent d952146 commit 3aa9162
Show file tree
Hide file tree
Showing 7 changed files with 184 additions and 65 deletions.
1 change: 1 addition & 0 deletions packages/core/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -716,6 +716,7 @@ export type WriteModeProps = {
workspace: string;
specsName: Record<string, string>;
header: string;
needSchema: boolean;
};

export type GeneratorApiOperations = {
Expand Down
3 changes: 2 additions & 1 deletion packages/core/src/writers/single-mode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export const writeSingleMode = async ({
output,
specsName,
header,
needSchema,
}: WriteModeProps): Promise<string[]> => {
try {
const { path, dirname } = getFileInfo(output.target, {
Expand Down Expand Up @@ -89,7 +90,7 @@ export const writeSingleMode = async ({
data += generateMutatorImports({ mutators: formUrlEncoded });
}

if (!output.schemas) {
if (!output.schemas && needSchema) {
data += generateModelsInline(builder.schemas);
}

Expand Down
3 changes: 2 additions & 1 deletion packages/core/src/writers/split-mode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export const writeSplitMode = async ({
output,
specsName,
header,
needSchema,
}: WriteModeProps): Promise<string[]> => {
try {
const { filename, dirname, extension } = getFileInfo(output.target, {
Expand Down Expand Up @@ -69,7 +70,7 @@ export const writeSplitMode = async ({
? upath.join(dirname, filename + '.schemas' + extension)
: undefined;

if (schemasPath) {
if (schemasPath && needSchema) {
const schemasData = header + generateModelsInline(builder.schemas);

await fs.outputFile(
Expand Down
3 changes: 2 additions & 1 deletion packages/core/src/writers/split-tags-mode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export const writeSplitTagsMode = async ({
output,
specsName,
header,
needSchema,
}: WriteModeProps): Promise<string[]> => {
const { filename, dirname, extension } = getFileInfo(output.target, {
backupFilename: camel(builder.info.title),
Expand Down Expand Up @@ -74,7 +75,7 @@ export const writeSplitTagsMode = async ({
? upath.join(dirname, filename + '.schemas' + extension)
: undefined;

if (schemasPath) {
if (schemasPath && needSchema) {
const schemasData = header + generateModelsInline(builder.schemas);

await fs.outputFile(schemasPath, schemasData);
Expand Down
3 changes: 2 additions & 1 deletion packages/core/src/writers/tags-mode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export const writeTagsMode = async ({
output,
specsName,
header,
needSchema,
}: WriteModeProps): Promise<string[]> => {
const { filename, dirname, extension } = getFileInfo(output.target, {
backupFilename: camel(builder.info.title),
Expand Down Expand Up @@ -78,7 +79,7 @@ export const writeTagsMode = async ({
? upath.join(dirname, filename + '.schemas' + extension)
: undefined;

if (schemasPath) {
if (schemasPath && needSchema) {
const schemasData = header + generateModelsInline(builder.schemas);

await fs.outputFile(schemasPath, schemasData);
Expand Down
1 change: 1 addition & 0 deletions packages/orval/src/write-specs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ export const writeSpecs = async (
output,
specsName,
header,
needSchema: !output.schemas && output.client !== 'zod',
});
}

Expand Down
Loading

1 comment on commit 3aa9162

@vercel
Copy link

@vercel vercel bot commented on 3aa9162 Apr 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.