最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Openapi generator maven plugin supporting custom file for template - Stack Overflow

programmeradmin0浏览0评论

I am trying to figure out if openapi-generator-maven-plugin supports customization like the original generator that allows use defined templates like:

templateDir: my_custom_templates
additionalProperties:
  artifactId: kotlin-petstore-client
  serializableModel: "true"
  dateLibrary: java8
files:
  AUTHORS.md: {}
  api_interfaces.mustache:
    templateType: API
    destinationFilename: Interface.kt
  api.mustache:
    templateType: API
    destinationFilename: Impl.kt
  other/check.mustache:
    folder: scripts
    destinationFilename: check.sh
    templateType: SupportingFiles

Does anyone know how to reprocess api model with another mustache again?

I am trying to figure out if openapi-generator-maven-plugin supports customization like the original generator that allows use defined templates like:

templateDir: my_custom_templates
additionalProperties:
  artifactId: kotlin-petstore-client
  serializableModel: "true"
  dateLibrary: java8
files:
  AUTHORS.md: {}
  api_interfaces.mustache:
    templateType: API
    destinationFilename: Interface.kt
  api.mustache:
    templateType: API
    destinationFilename: Impl.kt
  other/check.mustache:
    folder: scripts
    destinationFilename: check.sh
    templateType: SupportingFiles

Does anyone know how to reprocess api model with another mustache again?

Share Improve this question asked Feb 6 at 15:59 Patryk ImosaPatryk Imosa 8142 gold badges11 silver badges32 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

I found the solution by myself. The documentation lacks information that this "files" could be put on configurationFile in json format:

{
  "basePackage": "mypackage",
  "apiPackage": "mypackage",
  "configPackage": "mypackage.config",
  "modelPackage": "mypackage.model",
  "files": {
    "myheaders.mustache": {
      "templateType": "SupportingFiles",
      "folder": "src/gen/java/mypackage",
      "destinationFilename": "ServiceYamlHeaders.java"
    }
  }
}

So you have to specify the path to this config file in the plugin

    <plugin>
        <groupId>org.openapitools</groupId>
        <artifactId>openapi-generator-maven-plugin</artifactId>
        <version>${openapi.codegen.maven.plugin.version}</version>
        <executions>
            <execution>
                <id>service</id>
                <goals>
                    <goal>generate</goal>
                </goals>
                <configuration>
                    <inputSpec>myyaml.yaml</inputSpec>
                    <configurationFile>packageBoot-service.json</configurationFile>

Anyway I still struggle how to access all headers parameters only without looping through operations and apis...

发布评论

评论列表(0)

  1. 暂无评论