Skip to content

Customization of folder structure for a template #3515

@osher

Description

@osher
Description

I'm not sure I'm in the right place, please bear with me...

  1. I'm evaluating the tools for a nodejs team.
  2. I need to customize the folder structure: add a generated tests folder, separate the web-controllers from the "services" (uh, we don't call them services in node...)
    and such.

For example,

eval-codegen-nodejs
│   .swagger-codegen-ignore
│   index.js
│   LICENSE
│   package.json
│   README.md
├───api
│       swagger.yaml
└───controllers
        <name>.js
        <name>Service.js

to:

eval-codegen-nodejs
│   .swagger-codegen-ignore
│   LICENSE
│   package.json
│   README.md
├───bin
│   └──server.js
├───scheme
│   └──scheme.yaml
├───lib
│   └──<name>.js
├───web
│   └──<name>.js
└─── test
    ├───lib.web.index.js
    └───lib.    

I don't find any documentations about it :(
Can anybody point me to the right direction?

Swagger-codegen version

cloned from master + a PR I applied (which was merged to master)
So call it 2.2.1-latest?

Swagger declaration file content or url

This is not a bug the spec file produces.

Command line used for generation
java -jar swagger-codegen\modules\swagger-codegen-cli\target\swagger-codegen-cli.jar generate -l nodejs-server -o eval-codegen-hello -i hello.openapi.yaml -t swagger-codegen-nodejs

(windows user)

Steps to reproduce

It works, but I want it to work differently.
I want to control the folder-structure.

Related issues

none

Suggest a Fix

Maybe it's a completely new feature request.

Ideally,
As a user - I want to provide a path, and a list of a per-controller files (call it option 1)
or - alternatively - a project dir path, a controller-router dir path (call it option 2)

Then, the expected behavior would be:

every file in the project dir recursively is bound with the model once and rendered to the target folder, preserving relative path it's found in the source dir

if we're doing 1st option - the files listed as per-controller-router files are excluded of the first round, but are bound once per controller-router with a model that features also a reference to the current operation (can be null when binding project files)

if we're doing 2nd option - then, recursively, per controller-router - every file in the controller dir path is bound with the model once and rendered to the target folder, again preserving relative path it's was found in the source dir
(2nd option probably allow more code-reuse with the folder-structure recursion and all...)

I deem this will grant enough control to use codeGen to provide any folder structure.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions