Skip to content

[go-server] fix imports with go generation#18514

Merged
wing328 merged 7 commits intoOpenAPITools:masterfrom
darkrift:fix_go_imports_5153
May 1, 2024
Merged

[go-server] fix imports with go generation#18514
wing328 merged 7 commits intoOpenAPITools:masterfrom
darkrift:fix_go_imports_5153

Conversation

@darkrift
Copy link
Contributor

@darkrift darkrift commented Apr 26, 2024

This fixes the import issues raised in issue 5153

PR checklist

  • Read the contribution guidelines.
  • Pull Request title clearly describes the work in the pull request and Pull Request description provides details about how to validate the work. Missing information here may result in delayed response from the community.
  • Run the following to build the project and update samples:
    ./mvnw clean package 
    ./bin/generate-samples.sh ./bin/configs/*.yaml
    ./bin/utils/export_docs_generators.sh
    
    (For Windows users, please run the script in Git BASH)
    Commit all changed files.
    This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
    These must match the expectations made by your contribution.
    You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example ./bin/generate-samples.sh bin/configs/java*.
    IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
  • File the PR against the correct branch: master (upcoming 7.1.0 minor release - breaking changes with fallbacks), 8.0.x (breaking changes without fallbacks)
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.

@darkrift darkrift closed this Apr 26, 2024
@darkrift darkrift reopened this Apr 26, 2024
@darkrift
Copy link
Contributor Author

@darkrift darkrift changed the title fix imports with go generation [GO] fix imports with go generation Apr 26, 2024
}

additionalProperties.put("hasPathParams", hasPathParams);
additionalProperties.put("hasBodyParams", hasBodyParams);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the PR. does this fix work for APIs with different tags (e.g. Pet, User) ? looks like if Pet APIs have an endpoint with body parameter while Users APIs doesn't have any body parameter, hasBodyParams is also set to true for Users APIs (operations).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually added an open api spec and a sample generated code that creates 3 different api files with their own tags (api_none.go, api_body.go, api_path.go) to test 3 different cases, I haven't make a case for "both" but the logic is independent for both case and just a combination of body and path tag.

Each of them has the imports according to what they need to use.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's good. I'll do some tests later to confirm

@@ -0,0 +1,8 @@
generatorName: go-server
outputDir: samples/server/others/go-server/no-body-path-params
Copy link
Member

@wing328 wing328 Apr 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add the output folder to .github/workflows/samples-go.yaml so that the CI can test the output moving forward

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@wing328 wing328 added this to the 7.6.0 milestone Apr 30, 2024
@darkrift darkrift requested a review from jimschubert as a code owner April 30, 2024 18:58
@wing328 wing328 changed the title [GO] fix imports with go generation [go-server] fix imports with go generation May 1, 2024
@wing328
Copy link
Member

wing328 commented May 1, 2024

thanks for the fix.

let's give it a try

@wing328 wing328 merged commit 10897ca into OpenAPITools:master May 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants