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

Optional wrapper #33

Merged
merged 4 commits into from
Aug 2, 2019
Merged

Optional wrapper #33

merged 4 commits into from
Aug 2, 2019

Conversation

scvnathan
Copy link
Contributor

@scvnathan scvnathan commented Jul 24, 2019

I would rather that the default behavior be no wrapper, but that would be a breaking change.
Of course, I'm open to any other way to make wrapper optional

@codecov
Copy link

codecov bot commented Jul 24, 2019

Codecov Report

Merging #33 into master will increase coverage by 0.08%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #33      +/-   ##
==========================================
+ Coverage   97.84%   97.93%   +0.08%     
==========================================
  Files           2        2              
  Lines          93       97       +4     
  Branches       34       37       +3     
==========================================
+ Hits           91       95       +4     
  Misses          2        2
Impacted Files Coverage Δ
src/swagger-2.ts 97.8% <100%> (+0.1%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0337910...4df64b1. Read the comment docs.

@scvnathan
Copy link
Contributor Author

This doesn't work with the CLI yet, working on a fix for that

@@ -22,7 +22,7 @@ export interface Swagger2 {

export interface Swagger2Options {
camelcase?: boolean;
wrapper?: string;
wrapper?: string | false;
Copy link
Contributor

Choose a reason for hiding this comment

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

Rather than having this be a union type, maybe we should just have const shouldUseWrapper = options.wrapper !== undefined ? And we can just make this property optional.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah sorry—brainfart. It is nice having declare namespace OpenAPI be the default. I’m fine with this as-is.

@drwpow
Copy link
Contributor

drwpow commented Jul 26, 2019

This doesn't work with the CLI yet, working on a fix for that

Just changing the following in bin/cli.js should work?

wrapper: {
-  type: 'string',
+  type: 'string | boolean', 

Not sure how to specify true as a type, but unless I’m mistaken, passing true in your code should just return the default (declare namespace OpenAPI)

@drwpow
Copy link
Contributor

drwpow commented Jul 26, 2019

Overall, this looks great! Happy to :shipit: this once it’s working with the CLI

@scvnathan
Copy link
Contributor Author

Hey @DangoDev I'll have some time today to work on this again, so I should have something later. The problem I was running into with the cli is that the value was coming in as a string so the triple equals check on options.wrapper wasn't working

@scvnathan
Copy link
Contributor Author

Just changing the following in bin/cli.js should work?

wrapper: {
-  type: 'string',
+  type: 'string | boolean', 

Unfortunately this didn't work. I'm not sure if meow supports union types like that.

@drwpow
Copy link
Contributor

drwpow commented Jul 30, 2019

I'm not sure if meow supports union types like that.

Oh you’re right. I haven’t used that before, but misread the meow docs. Hm. The CLI is just a wrapper around the function, so the CLI arguments don’t have to match exactly. Maybe you could pass a --nowrapper option or something?

@drwpow
Copy link
Contributor

drwpow commented Jul 30, 2019

Also I think this is good enough to merge as-is; LMK if you’re interested in writing docs for this, or if not I can merge this and wrap up in a separate PR

@scvnathan
Copy link
Contributor Author

Apologies for the lack of docs 😅, I can add some but I'm away from my computer at the moment.
Also if you prefer nowrapper I don't mind changing it.

Feel free to merge if you like as I probably won't be able to get to this until tonight.

@drwpow
Copy link
Contributor

drwpow commented Jul 30, 2019

@scvnathan I’m in no rush! Just offering to help out if you’d like it. I’m happy to let you push this PR as far as you’d like / have time for, and I can do the rest. Just tag me whenever you’re done!

@drwpow
Copy link
Contributor

drwpow commented Jul 31, 2019

This looks good to me! I’ll approve this, and let you merge when you’re happy with it. I’ll test it locally myself then publish a new version. Awesome work!

@drwpow drwpow merged commit e962f61 into openapi-ts:master Aug 2, 2019
@MrCrunchwrap
Copy link

The cli --nowrapper option doesn't seem to work properly. I'm using it in my command and my types are still wrapped with declare namespace OpenAPI2

@drwpow
Copy link
Contributor

drwpow commented Aug 5, 2019

@MrCrunchwrap Sorry—I’ve been traveling and latest npm release isn’t in-step with master, so that option isn’t available yet. I’m going to test it a bit more and then cut a new release soon.

@drwpow
Copy link
Contributor

drwpow commented Aug 5, 2019

@MrCrunchwrap Just published version 1.3.0 that contains the --nowrapper option for the CLI, but if using npx it should automatically pick up on the new version. Beyond that, please let me know if you have any difficulty using this!

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

Successfully merging this pull request may close these issues.

3 participants