I am trying out the code generation tools with API IDL like swagger, grpc etc.
Most of these tools create a seperate class for Service Client and a Model class
for e.g. If I have a Service call User with method get which returns all Users like
"/users":{
"get": {
"summary": "get a user",
"description": "",
"operationId": "getUsers",
"responses": {
"200": {
"description": "successful operation",
"schema": {
"$ref": "#/definitions/Users"
}
}
}
}
},
"definitions": {
"User": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"username": {
"type": "string"
},
"firstName": {
"type": "string"
},
"lastName": {
"type": "string"
},
"groupid": {
"type": "integer"
}
}
},
I don't want to create different classes for UserAPIClient and User data model, I want one class User to have method getUsers which will handle the API call and return the result, like an ORM, is this possible in swagger OpenAPI code gen tool or any other code gen tool like grpc, thrift etc
Thanks
It seems this is not possible, since all the codegen tools generate code with API client as a separate class than the model class (MVC pattern). Mixing the two is not recommended as a good practice.