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

Add hashableModels to additional properties #9495

Merged

Conversation

maoyama
Copy link
Contributor

@maoyama maoyama commented May 16, 2021

Resolves #9473 , Related #9166

  • Add hashableModels to additional properties (default: true)
  • Revert x-swift-hashable

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/utils/export_docs_generators.sh
    
    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*.
    For Windows users, please run the script in Git BASH.
  • File the PR against the correct branch: master, 5.1.x, 6.0.x
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.
    @jgavris (2017/07) @ehyche (2017/08) @Edubits (2017/09) @jaz-ah (2017/09) @4brunu (2019/11)

@maoyama maoyama force-pushed the add-hashableStruct-to-additional-properties branch from 977243a to a0bce08 Compare May 16, 2021 16:25
@maoyama maoyama force-pushed the add-hashableStruct-to-additional-properties branch from a0bce08 to e525215 Compare May 16, 2021 16:28
@maoyama maoyama changed the title Add hashable struct to additional properties Add hashableStruct to additional properties May 16, 2021
@4brunu
Copy link
Contributor

4brunu commented May 18, 2021

@maoyama Thanks for opening this PR.
Overall it looks good.

But could you please rename the option hashableStruct to hashableModels?
Because the models can either be a struct or a class.

- Replace hashableStruct => hashableModels
- Replace HashableStruct => HashableModels
- Replace HASHABLE_STRUCT => HASHABLE_MODELS
- Update docs
@maoyama
Copy link
Contributor Author

maoyama commented May 18, 2021

@4brunu You’re right.
I rename the option hashableStruct to hashableModels.

@maoyama maoyama changed the title Add hashableStruct to additional properties Add hashableModels to additional properties May 18, 2021
@@ -1,4 +1,4 @@
{{^objcCompatible}}{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} {{#useClasses}}final class{{/useClasses}}{{^useClasses}}struct{{/useClasses}} {{classname}}: Codable, Hashable {
{{^objcCompatible}}{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} {{#useClasses}}final class{{/useClasses}}{{^useClasses}}struct{{/useClasses}} {{classname}}: Codable{{#vendorExtensions.x-swift-hashable}}, Hashable{{/vendorExtensions.x-swift-hashable}} {
Copy link
Contributor

Choose a reason for hiding this comment

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

@maoyama shouldn't we also check here for {{#hashableModels}}...{{/hashableModels}}?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@4brunu We don't have to check here.
I set x-swift-hashable to true when hashableModels is true to reduce the logic in modelObject.mustache. fb2c45f

Copy link
Contributor

Choose a reason for hiding this comment

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

Nice, good idea! 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks!

@4brunu
Copy link
Contributor

4brunu commented May 18, 2021

Looks good to me, let's wait for the CI to finish

@4brunu
Copy link
Contributor

4brunu commented May 18, 2021

CI is failing, but it's not related to this PR.

@wing328 wing328 added this to the 5.2.0 milestone May 20, 2021
@wing328 wing328 merged commit 0a34839 into OpenAPITools:master May 20, 2021
premiumitsolution pushed a commit to premiumitsolution/openapi-generator that referenced this pull request May 26, 2021
* Add hashableStruct

* Revert "Remove x-swift-hashable"

This reverts commit 18053af.

* Add Hashable for x-swift-hashable

* Add config yaml to test x-swift-hashable

* Run ./bin/generate-samples.sh ./bin/configs/swift5*

* Run ./bin/utils/export_docs_generators.sh

* Run ./bin/generate-samples.sh ./bin/configs/swift5*

* Verify setHashableStruct

* Rename hashableStruct => hashableModels

- Replace hashableStruct => hashableModels
- Replace HashableStruct => HashableModels
- Replace HASHABLE_STRUCT => HASHABLE_MODELS
- Update docs

* Refactor modelObject.mustache

* Control equals and hash functions
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.

[REQ][swift5] Add config flag to control Hashable conformance behavior
3 participants