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

[swift5] Refactor encodeToJSON #10961

Merged
merged 7 commits into from
Nov 25, 2021

Conversation

funzin
Copy link
Contributor

@funzin funzin commented Nov 25, 2021

Refactor encodeToJSON
Some types return self only so we can skip same code using protocol extension method.
if type is UUID, Int16, Int32, we can return self.
I checked correct judgment.
Screen Shot 2021-11-25 at 20 49 09

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.3.0), 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.

@funzin
Copy link
Contributor Author

funzin commented Nov 25, 2021

@4brunu
Please review it when you have time.

@@ -0,0 +1,24 @@
set(CPACK_PACKAGE_NAME lib${pkgName})
Copy link
Contributor

Choose a reason for hiding this comment

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

@funzin is this here by accident?

Copy link
Contributor Author

@funzin funzin Nov 25, 2021

Choose a reason for hiding this comment

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

Reverted d1aa1c9, 5a39068

I excuted these commands and then the diff was appeared 🤔

./mvnw clean package 
./bin/generate-samples.sh

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Comment on lines 68 to 70
}

extension URL: JSONEncodable {
func encodeToJSON() -> Any {
return self
}
}

extension UUID: JSONEncodable {
func encodeToJSON() -> Any {
return self.uuidString
}
}{{/useVapor}}{{#generateModelAdditionalProperties}}
{{/useVapor}}{{#generateModelAdditionalProperties}}
Copy link
Contributor

Choose a reason for hiding this comment

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

@funzin can you please make this one line only to avoid generate extra new lines? Thanks

}{{/useVapor}}{{#generateModelAdditionalProperties}}

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 unserstand:+1:
Remove empty lines
e69c46f

@4brunu
Copy link
Contributor

4brunu commented Nov 25, 2021

Hum, it looks like it's a file from the c generator that was not generated properly.
Could you please add it to fix CI?
Sorry for the change

@funzin
Copy link
Contributor Author

funzin commented Nov 25, 2021

Add Packing.cmake
0e424f4

@funzin
Copy link
Contributor Author

funzin commented Nov 25, 2021

Circle CI & BItrise failed but it's not related to this pr

Copy link
Contributor

@4brunu 4brunu left a comment

Choose a reason for hiding this comment

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

I can confirm that CI failure is not related to this PR.
Looks good to me 👍
@funzin thanks for creating multiple PR that improve the Swift Generator.
Looking forward to review more PRs of yours 👍

@wing328
Copy link
Member

wing328 commented Nov 25, 2021

I've restarted https://app.bitrise.io/build/69fe6309-6ba6-4859-bbf0-b3890d47fc53#?tab=log. Let's see how it goes

@wing328 wing328 merged commit a620853 into OpenAPITools:master Nov 25, 2021
@wing328 wing328 added Client: Swift Enhancement: Code Cleanup General refactoring, removal of deprecated things, commenting, etc. labels Nov 25, 2021
@wing328 wing328 added this to the 5.3.1 milestone Nov 25, 2021
@funzin funzin deleted the swift5/encodable-to-json branch November 25, 2021 22:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Client: Swift Enhancement: Code Cleanup General refactoring, removal of deprecated things, commenting, etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants