Swagger Codegen use existing class

后端 未结 3 2176
醉酒成梦
醉酒成梦 2021-02-15 16:06

How can I get the swagger codegen to use an existing class instead of creating a new class? Is this possible? For instance I want to use org.springframework.data.domain.Pa

3条回答
  •  醉酒成梦
    2021-02-15 16:28

    It's not always possible to use --import-mappings if you have long list of mappings. (At least in case of Windows, which has size-limit for string in command prompt.) That is why better way do it: use mapping with swagger configuration file. (And this option is not fully documented.)

    Like that:

    java -jar swagger-codegen-cli-2.3.1.jar generate -i myspec.yaml -l java -c myconfig.json

    myconfig.json:

    {
      "hideGenerationTimestamp": true,
      "dateLibrary": "java8",
      "useRuntimeException": true,
      "modelPackage": "org.my.package.model",
      "apiPackage": "org.my.package.api",
      "importMappings": {
        "Page": "org.springframework.data.domain.Page",
        "MySuperType": "org.my.SuperType"
      }
    }
    

提交回复
热议问题