api-client-generator icon indicating copy to clipboard operation
api-client-generator copied to clipboard

Restriction of subsets of swagger-files used for generation

Open paveltobias opened this issue 5 years ago • 1 comments

A single swagger-file might:

  • be shared between several front-ends, each of which use different parts of it;
  • contain endpoints not meant to be consumed by any front-end, but rather used for web hooks etc.

Currently there is no way to restrict which definitions and paths/endpoints will be used for model+service generation, i.e. some of them might be superfluous for a given front-end. It would be nice to have (at least) one of the following features:

  • A program option allowing to specify a pattern (PCRE?) that has to be matched by an endpoint's path -- otherwise the path is not generated into a service method. Definitions unused by any of the matching paths should not be generated into models either.
  • Recognition of a custom non-standard flag (e.g. something like x-acg-omit: true) used to tag an endpoint (= [path, HTTP-method]). The result would, again, be the omission of the given endpoint and consequently unused definitions.

Does it sound reasonable?

paveltobias avatar Feb 06 '20 17:02 paveltobias

As of right now, the tags might be able to solve this. With each endpoint, you can specify a tags string array in to distinguish the endpoints used for "user-consumption" and for "other-purposes" and then generate only certain tags. But this would group all the endpoints under one tag to the same service.

ad x-acg-omit: true I can see the benefit of being able to specify it manually, but I'm not sure if such a feature is needed as auto-gen tools will not support it and you'd always have to manually edit the swagger file, which is close to manually deleting such methods from API service or ignoring them.

ad PCRE this could be more useful as you could use the "path based filter" on more use-cases than just this one.


It would be nice to see if there are similar needs coming from more users.

vmasek avatar Dec 02 '20 13:12 vmasek