Skip to content

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

@prastoin

Description

@prastoin

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 !

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions