flowup / api-client-generator

Angular REST API client generator from Swagger YAML or JSON file with camel case settigs
MIT License
115 stars 21 forks source link

new options --apiName & --skipModule #59

Closed admir86 closed 6 years ago

admir86 commented 6 years ago

added new options.

-n, --apiName possibility to use only a subset of the swagger definitions as input for the generator. For this I use the operationId field to filter the definitions (filter by operationId works for me but perhaps is better to filter by tag?) with this options only needed models will be generated and the angular service gets the name of the apiName parameter.

example:

"paths": {
        "/api/dummyselector/{organizerTaskElementId}": {
            "get": {
                "tags": [
                    "DummySelector"
                ],
                "operationId": "DummySelector_Get",
                "consumes": [],
                "produces": [
                                         ...
                ],
                "parameters": [
                    {
                                          ...
                    }
                ],
                "responses": {
                                        ...
                }
            }
        },
                ...
}

calling api-client-generator with -n DummySelector will fetch all paths where operationId starts with DummySelector

-m, --skipModule if you don't need the module, you can use this option to skip creating the index file with the module export

CLAassistant commented 6 years ago

CLA assistant check
All committers have signed the CLA.

vmasek commented 6 years ago

@admir86 Thank you for your PR 👍 I'll try to review it soon.

I noticed there are some code format changes which shouldn't be included in PR.

admir86 commented 6 years ago

@vmasek ok thx. the code format changes are probably from vs code (format on save) sorry for that.

By the way, the tests are broken since the swagger file validation step.

vmasek commented 6 years ago

Preferably I would also pick tags for splitting API client to multiple services as it is much more explicit.

@admir86 so with this PR you will be able to create (generate) one API service at the time (based on the tag name), I think it would be best to extend it so you will be able to specify which tags should be generated as a list.

One more thing is, the skip module option is because of services being part of the module and you want to provide them separately in modules where you use them?

admir86 commented 6 years ago

@vmasek thx for your feedback.

I think it would be best to extend it so you will be able to specify which tags should be generated as a list.

If there are more than one tag passed to the generator, would you create for each tag/api a separate file/service or should the behavior be same, like without this splitPathTags option (all apis in same file)

Parameter name 'apiName' should be changed to something more semantically correct, for example, splitPathTags (feel free to come up with something better 😄 )

I was inspired by the selective generation option from swagger-codegen but the name splitPathTags is ok :)

One more thing is, the skip module option is because of services being part of the module and you want to provide them separately in modules where you use them?

yes that's correct

vmasek commented 6 years ago

@admir86 It would create separate service for each tag.

Also, it could support generating all tag+service options, if some special value is used (all) or if the flag is used with no parameter?

admir86 commented 6 years ago

ok I'll try :) maybe tomorrow or next days...

admir86 commented 6 years ago

now better? feel free to make some code refactoring :)

admir86 commented 6 years ago

@vmasek thx!

vmasek commented 6 years ago

Thank you for your collaboration :+1: I was planning to as such a functionality but didn't get to it in time :smile:

Now tests are the priority, later I will probably be extending it more.