fmvilas / swagger-node-codegen

An OpenAPI 3.x/Swagger 2 code generator for Node.js
Apache License 2.0
200 stars 55 forks source link

Pass the whole swagger/openapi spec into the operation files #28

Closed Vaelor closed 6 years ago

Vaelor commented 6 years ago

I currently have a case where it would make my life easier if I had access to other parts of the swagger spec (like components) in an operation file (___.js). The only context I have there is 'operation'.

Do you think it makes sense to include that there? (if I happen to have the time for it, I could also implement it)

I would assume https://github.com/fmvilas/swagger-node-codegen/blob/master/lib/codegen.js#L76 would be a place to start (next to operation also provide the whole openapi object, so existing implementations wouldn't break ofc)

fmvilas commented 6 years ago

It makes sense @Vaelor. A PR would be appreciated :).

Vaelor commented 6 years ago

Great :-) I will get on it as soon as I can :-)

Vaelor commented 6 years ago

So, just throwing config.data.swagger in there as swagger (so it can be used the same as in the other files as @root.swagger.endpoints for example) in there does seem to work without any further complications.

Will make a PR later today then, when I had a chance to check it more thorough.

fmvilas commented 6 years ago

I'm closing this issue as #31 has been merged. Thanks @Vaelor!

fmvilas commented 6 years ago

I just did a release and published to npm: https://github.com/fmvilas/swagger-node-codegen/releases/tag/1.3.0.

Vaelor commented 6 years ago

Thanks a lot! :)