Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
grokify opened this issue Jul 8, 2018 · 3 comments

Comments

@grokify
Copy link
Member

grokify commented Jul 8, 2018

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.

@wing328
Copy link
Member

wing328 commented Aug 29, 2018

UPDATE: I'm working on adding a hook so that we can post-process each auto-generated file.

@wing328
Copy link
Member

wing328 commented Aug 29, 2018

I've filed #929 to add postProcessFile and update Go generator to use it with gofmt -w. The results look good so far. Please have a look when you've time.

@wing328
Copy link
Member

wing328 commented Sep 1, 2018

Closed via #929

@grokify please pull the latest to give it a try when you've time.

@wing328 wing328 closed this as completed Jan 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants