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

[WIP] Add SwaggerConfig.outputBasename (needs tests) #589

Closed
wants to merge 21 commits into from

Conversation

edbrannin
Copy link
Contributor

All Submissions:

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same update/change?
  • Have you written unit tests?
  • Have you written unit tests that cover the negative cases (i.e.: if bad data is submitted, does the library respond properly)?
  • This PR is associated with an existing issue?

Closing issues

closes #360

If this is a new feature submission:

  • Has the issue had a maintainer respond to the issue and clarify that the feature is something that aligns with the goals and philosophy of the project?

Potential Problems With The Approach

  • Currently the definition for SwaggerConfig.outputBasename? is right next to outputDirectory, but that violates a potential "All optional settings are below all required settings" that might be going on here. Should I move it down?

Test plan

WIP: There aren't tests yet. I haven't been able to find any unit tests for this function, and I'd appreciate some guidance.

It looks like they might belong in tests/unit/swagger/config.spec.ts.

I don't see any tests referencing fsWriteFile or fsReadFile -- would you prefer I actually write/read the swagger config or try to mock out fsWriteFile()? If mock, can you point me at another place where you're mocking?

Jan Reusch and others added 13 commits December 18, 2019 02:45
OpenApi 3.0 allows to no specify a scheme/host in the server URL part,
in which case the scheme/host of the location where the document is
served from should then be used by follup consumers.
Until now if nothing special was specified always localhost:3000 was
taken as default.
To not break backwards compatability only enable relative locations when
explicitly specifying "null" as host.

This should most likely be changed with a new major breaking version.

Fixes: lukeautry#540
* add ability to handle streams returned from controller

* add test case for streamed buffer

* reuse BufferType for Streamable results

* improve stream ducktyping in express template
…tions

Allow relative locations for OpenApi server URLs
> inside your own code base (i.e. it does **not** live in `./node_modules`)

This seems like there's a word missing, though I'm new to the project so I _could_ be missing something.
Add a missing "not" in the docs:
@edbrannin edbrannin requested a review from dgreene1 February 20, 2020 02:09
@dgreene1
Copy link
Collaborator

@edbrannin I’m not at my desk so I can’t find the tests for you but if I recall properly there is an integration test folder that actually calls the tsoa CLI functions. That’s where you would want to change the config and then write an assertion that the file was created with the expected file name.

AlexChambers and others added 3 commits February 20, 2020 10:06
Markdown will now render the two lines as separate
README: minor Markdown improvement
@github-actions
Copy link

This PR 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

@github-actions github-actions bot added the Stale label Mar 22, 2020
@edbrannin
Copy link
Contributor Author

(While there are CLI-based integration tests, none of them actually look at the output yet. I'm going to have a look now and see if any of them actually generate output, then copy that one and change the output path.)

@edbrannin
Copy link
Contributor Author

After staring at the lack of CLI-oriented integration tests for a minute, I've extracted export const getSwaggerOutputPath = (swaggerConfig: SwaggerConfig) and I'm adding tests for that in tests/unit/swagger/definitionsGeneration/generateSwaggerSpec.spec.ts

@WoH WoH requested review from WoH and removed request for dgreene1 March 26, 2020 14:45
@WoH WoH removed the Stale label Mar 26, 2020
src/config.ts Outdated Show resolved Hide resolved
src/config.ts Outdated Show resolved Hide resolved
@edbrannin edbrannin marked this pull request as ready for review March 26, 2020 16:34
import 'mocha';
import { getSwaggerOutputPath, SwaggerConfig } from '../../../../src/module/generate-swagger-spec';

const fakeSwaggerConfig = ({ outputDirectory, yaml, outputBasename, ...more }: { outputDirectory: string; yaml?: boolean; outputBasename?: string }) => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a getDefaultOptions method you can reuse here.

Copy link
Collaborator

@WoH WoH left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See the comments for the few remaining issues. I'd love to ship this in 3.x, can you target 3.x instead of master please?

@edbrannin edbrannin changed the base branch from master to 3.x April 10, 2020 14:20
edbrannin and others added 4 commits April 10, 2020 10:21
Co-Authored-By: Wolfgang Hobmaier <wolfgang.hobmaier@sensoring.de>
Co-Authored-By: Wolfgang Hobmaier <wolfgang.hobmaier@sensoring.de>
Co-Authored-By: Wolfgang Hobmaier <wolfgang.hobmaier@sensoring.de>
@edbrannin
Copy link
Contributor Author

I tried pulling from 3.x, but got a number of unrelated conflicts. I imagine I might be better off rebasing?

@WoH
Copy link
Collaborator

WoH commented Apr 14, 2020

I tried pulling from 3.x, but got a number of unrelated conflicts. I imagine I might be better off rebasing?

Yes, I believe that'll be easier. Start from a fresh master and maybe cherry-pick your commits on top.

@github-actions
Copy link

This PR 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

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

Successfully merging this pull request may close these issues.

Add option to change output filename
5 participants