Skip to content

[DefaultCodegen] Need to hook into generator after all files have been created #507

Description

@grokify
Description

I'd like to add some post generation functionality after a generator has created all the files.

Specifically, I'd like to call gofmt for the files being produced by the Go client generator. I have a working implementation but I'm currently overriding postProcessSupportingFileData with the following:

@Override
public Map<String, Object> postProcessSupportingFileData(Map<String, Object> objs) {
    generateYAMLSpecFile(objs);
    objs = super.postProcessSupportingFileData(objs);
    gofmt();
    return objs;
}

When I do this, gofmt gets called after the models and APIs but before the supporting files including client.go and README.md

It seems a new hook may be needed to execute some code in DefaultGenerator.generate after generateSupportingFiles and processOpenAPI.

This may also be useful for the "Additional tools" section of the roadmap:

  1. node.js build system(s) integration (grunt/gulp/webpack/etc)
  2. ruby gem
  3. others (which may require previously mentioned SaaS API)
openapi-generator version

3.1.0 / master

OpenAPI declaration file content or url

n/a

Command line used for generation

n/a

Steps to reproduce

n/a

Related issues/PRs

https://stackoverflow.com/questions/51215890/openapi-generator-swagger-codegen-how-to-add-a-function-after-all-files-have

Suggest a fix/enhancement

Add a hook like postProcessFinalize that runs after supporting files are run.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions