0

I have below YAML for swagger-codegen and I want it to generate this endpoints in two separate classes, by default it generates one api class with both endpoints, is it s way to mark them as separate api?

/tenants:
post:
  produces:
    - application/json
  consumes:
    - application/json
  parameters:
    - name: body
      in: body
      required: true
      schema:
        $ref: "#/definitions/TenantRequest"

#################### User ####################

/tenants/{tenantId}/users:
post:
  description: Create a User
  produces:
    - application/json
  consumes:
    - application/json
  parameters:
    - name: tenantId
      in: path
      required: true
      type: string
    - name: body
      in: body
      description: User object
      required: true
      schema:
        $ref: "#/definitions/UserRequest"
Aliaksei Stadnik
  • 1,692
  • 3
  • 15
  • 32
  • 1
    This is done in the `addOperationToGroup` method at DefaultCodegen.java called by `processOperation` method at DefaultGeneratr.java, if you create your own client you can override the first one to put them into different operation groups (and therefor classes). But I don't think there is an easy way if you want to keep those endpoints. – moondaisy Jun 03 '17 at 16:26

1 Answers1

0

If you want separate APIs to be created then you need to change /tenants: to /createTenants:

say for example you have 2 operations.

/user/add
/user/delete

If you try to generate API classes for the above operation then it will create class named UserApi with add and delete methods in it.

Now if you want separate API classes for add and delete then you need to change the end point as follows.

/addUser
/deleteUser
Jobin
  • 5,610
  • 5
  • 38
  • 53
  • 1
    I got this but the question - is it a way to generate separate classes for the endpoints with the same beginning. As I would have CRUD for tenants and CRUD for tenants/id/users and I do not want to store them in one class. – Aliaksei Stadnik May 30 '17 at 10:58