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

Add option to change output filename #360

Closed
HoldYourWaffle opened this issue Jun 10, 2019 · 13 comments · Fixed by #361 or #807
Closed

Add option to change output filename #360

HoldYourWaffle opened this issue Jun 10, 2019 · 13 comments · Fixed by #361 or #807

Comments

@HoldYourWaffle
Copy link
Contributor

The routes.ts output filename is currently hard coded:

const fileName = `${this.options.routesDir}/routes.ts`;

I'd love to have an option to change this filename. I was going to make a PR for this, but the fact that such a trivial thing hasn't been implemented yet makes me wonder if there's an actual reason for it.

@lukeautry
Copy link
Owner

There really isn't a reason. Feel free to PR to make it configurable.

@HoldYourWaffle
Copy link
Contributor Author

#361

HoldYourWaffle added a commit to HoldYourWaffle2/tsoa that referenced this issue Jun 10, 2019
HoldYourWaffle added a commit to HoldYourWaffle2/tsoa that referenced this issue Jun 10, 2019
HoldYourWaffle added a commit to HoldYourWaffle2/tsoa that referenced this issue Jun 10, 2019
HoldYourWaffle added a commit to HoldYourWaffle2/tsoa that referenced this issue Jun 10, 2019
@dgreene1
Copy link
Collaborator

@HoldYourWaffle what is the value in having the file name be different?

I believe there is a larger value in that if you’re a developer who is familiar with tsoa then you know that there will be a routes.ts file in the project. This provides consistency so that developers familiar with tsoa can move from project to project.

That’s why I’m wondering what the value is for changing the file name. It would have to be higher value than the benefit of consistency.

@HoldYourWaffle
Copy link
Contributor Author

The reason why I want to change filenames is because I use custom templates to generate both the server routes and the client SDK using TSOA. Having client.ts and server.ts makes a lot more sense in that case.

I do this because I want more control over generated code. Because both sides are in Typescript for me, Swagger/OpenAPI is an unnecessary middleman (and just generally very unhelpful). This also allows me to easily share things like type definitions across sides which is always very helpful.

@pdeak
Copy link

pdeak commented Aug 30, 2019

This feature is also very important for the swagger.json file. As of version 3 of the spec, it is no longer called Swagger. It is OpenAPI. It is wrong and misleading to call the output swagger.json.

It's more than just aesthetic though: Visual Studio Code with the openapi-lint extension automatically picks up *swagger.json files as OAS2, and therefore the linting and intellisense is broken until the file is renamed to openapi.json, which it will treat as OAS3.

Just as a final point, in my 20+ years as a developer, I have never come across a command line tool that doesn't let you (either via command line flags, or config files) override the output filename.

@HoldYourWaffle
Copy link
Contributor Author

I completely forgot that there's another filename that generates when creating the PR, we should definitely fix that.

@dgreene1 Should we create a new issue of this or reopen this one?
I'd be happy to implement this, should I go for the same approach as with router generation?

@dgreene1
Copy link
Collaborator

Sure I'll reopen this issue so you can add that @HoldYourWaffle. And@pdeak we'll get working on that for you. :)

@dgreene1 dgreene1 reopened this Aug 31, 2019
@HoldYourWaffle
Copy link
Contributor Author

@dgreene1 Can you please assign me to this issue so I don't forget?

@pdeak
Copy link

pdeak commented Sep 2, 2019

Thanks guys

@github-actions
Copy link

github-actions bot commented Oct 3, 2019

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days

@edbrannin
Copy link
Contributor

I'd like to take a stab at renaming swagger.json/yaml.

Naming things is hard; any thoughts on what you'd want the setting to be called? I see outputDirectory and yaml are the related settings in play.

Maybe outputFilename? But it would default to swagger and not swagger.json, so maybe outputBasename?

@dgreene1
Copy link
Collaborator

I like outputBasename and outputNameMinusExtension. Please choose whichever name of those two that you’d like and start the PR. If any reviewers have a strong preference they can let you know during the PR review. Thank you so much! :)

@calvinwyoung
Copy link

@edbrannin @WoH Are there any plans to complete PR #589? I'd also love the ability to rename the swagger.json file

@lucasrcosta lucasrcosta mentioned this issue Oct 7, 2020
5 tasks
@WoH WoH closed this as completed in #807 Oct 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment