Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Tag grouped] Import issue with common complex models #310

Open
prastoin opened this issue Oct 14, 2024 · 0 comments
Open

[Tag grouped] Import issue with common complex models #310

prastoin opened this issue Oct 14, 2024 · 0 comments

Comments

@prastoin
Copy link

prastoin commented Oct 14, 2024

Introduction

Hello there ! Hope you're doing great, first of all thanks for the great job on that project ! It was a pleasure going through.

The bug

It seems like there's an issue while importing common models, shared between at least 2 controllers, when tag grouping apis.

Reproduction

Please find playground reproduction here, please select the Group by tag ( split files ):

In case this is the used OpenApi spec

We can see that that in both Foo and Bar controllers FooBar schema import is missing

// controller_foo.ts
import { makeApi, Zodios, type ZodiosOptions } from "@zodios/core";
import { z } from "zod";

import { putFoo_Body } from "./common";

const endpoints = makeApi([
    {
        method: "put",
        path: "/foo",
        description: `Foo`,
        requestFormat: "json",
        parameters: [
            {
                name: "body",
                type: "Body",
                schema: putFoo_Body,
            },
        ],
        // Cannot find name FooBar
        response: z.array(FooBar),
    },
]);

export const Controller_fooApi = new Zodios(endpoints);

export function createApiClient(baseUrl: string, options?: ZodiosOptions) {
    return new Zodios(baseUrl, endpoints, options);
}

A fix ?

This is just a solution suggestion, that might not be the most idiomatic.
Please find #309

Conclusion

Please let me know your thoughts !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant