Skip to content

Missing models/index.ts after running lb4 openapi command #4135

Description

@dhmlau

After running the lb4 openapi command, models are created. However, there is no index.ts file in the models folder. If I generate the repository for the model, it will get an error during build:


src/repositories/pet.repository.ts:2:33 - error TS2307: Cannot find module '../models'.

2 import {Pet, PetRelations} from '../models';
                                  ~~~~~~~~~~~

It's not a big issue because I can create the index.ts, but generating the index.ts when generating the models would be helpful.

Steps to reproduce

  1. In a LB application, run
lb4 openapi https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/examples/v3.0/petstore-expanded.yaml
  1. It creates the Pet and NewPet and Error model.
  2. Create datasource and Repository
  3. Run npm run build.
    It gives the error I've shown above because of the missing index.ts to export the models.
    UPDATED: it also complained about PetRelations not imported in the repository class but it actually doesn't exist.

Acceptance Criteria

  • Generate the index.ts model file during lb4 openapi
  • the generated code should not have any build error. (about the missing {ModelName}Relations)

Metadata

Metadata

Assignees

Labels

CLIdeveloper-experienceIssues affecting ease of use and overall experience of LB users

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions