openapi generator cli - how to skip generation equals method

681 Views Asked by At

We are using the openapi-generator-cli-6.2.1 to generate the APIs and Models from swagger file. Is it possible to instruct the CLI not to generate any equals() method for the Model classes ? The reason is because the code generator generates malformed variable names for specific types.

Sample Swagger File

{
"swagger": "2.0",
"info": {
    "description": "Springfox template project",
    "version": "8.1.0",
    "title": "springfoxtemplate",
    "license": {
        "name": "Some Org"
    }
},
"host": "localhost:7777",
"basePath": "/",
"tags": [
    {
        "name": "main-controller",
        "description": "Main Controller"
    }
],
"paths": {
    "/cart/customer": {
        "get": {
            "tags": [
                "main-controller"
            ],
            "summary": "addCustomer",
            "operationId": "addCustomerUsingGET",
            "produces": [
                "application/json"
            ],
            "parameters": [
                {
                    "in": "body",
                    "name": "customer",
                    "description": "customer",
                    "required": true,
                    "schema": {
                        "$ref": "#/definitions/ShoppingCartRequest«Customer»"
                    }
                }
            ],
            "responses": {
                "200": {
                    "description": "OK",
                    "schema": {
                        "$ref": "#/definitions/ShoppingCartResponse«Customer»"
                    }
                },
                "401": {
                    "description": "Unauthorized"
                },
                "403": {
                    "description": "Forbidden"
                },
                "404": {
                    "description": "Not Found"
                }
            },
            "deprecated": false
        }
    },
    "/cart/nodes": {
        "get": {
            "tags": [
                "main-controller"
            ],
            "summary": "getNodes",
            "operationId": "getNodesUsingGET",
            "produces": [
                "application/json"
            ],
            "responses": {
                "200": {
                    "description": "OK",
                    "schema": {
                        "$ref": "#/definitions/ShoppingCartResponse«List«Nodes»»"
                    }
                },
                "401": {
                    "description": "Unauthorized"
                },
                "403": {
                    "description": "Forbidden"
                },
                "404": {
                    "description": "Not Found"
                }
            },
            "deprecated": false
        }
    }
},
"definitions": {
    "Customer": {
        "type": "object",
        "properties": {
            "id": {
                "type": "string"
            },
            "name": {
                "type": "string"
            },
            "status": {
                "type": "string"
            }
        },
        "title": "Customer"
    },
    "Nodes": {
        "type": "object",
        "properties": {
            "id": {
                "type": "string"
            },
            "name": {
                "type": "string"
            }
        },
        "title": "Nodes"
    },
    "ShoppingCartRequest«Customer»": {
        "type": "object",
        "properties": {
            "cartInstanceID": {
                "type": "string"
            },
            "requestObject": {
                "$ref": "#/definitions/Customer"
            }
        },
        "title": "ShoppingCartRequest«Customer»"
    },
    "ShoppingCartResponse«Customer»": {
        "type": "object",
        "properties": {
            "cartInstanceID": {
                "type": "string"
            },
            "responseObject": {
                "$ref": "#/definitions/Customer"
            },
            "status": {
                "type": "string"
            }
        },
        "title": "ShoppingCartResponse«Customer»"
    },
    "ShoppingCartResponse«List«Nodes»»": {
        "type": "object",
        "properties": {
            "cartInstanceID": {
                "type": "string"
            },
            "responseObject": {
                "type": "array",
                "items": {
                    "$ref": "#/definitions/Nodes"
                }
            },
            "status": {
                "type": "string"
            }
        },
        "title": "ShoppingCartResponse«List«Nodes»»"
    }
}}

CLI Command

java -jar ..\openapi-generator-cli-6.2.1.jar generate --skip-operation-example -g spring --library spring-boot -i local-shoppingcart.json

The codegen generates invalid variables in the equals() method

Any suggestion is appreciated

0

There are 0 best solutions below