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 models improvements #9205

Merged
merged 7 commits into from
Apr 24, 2021

Conversation

aymanbagabas
Copy link
Contributor

@aymanbagabas aymanbagabas commented Apr 7, 2021

  • Add the option to use final class instead of struct
  • Always include CodingKeys
  • Implement equals and hash funcs
  • Encode null values
  • Add useClasses to urlsessionLibrary config
  • Add a required nullable test case to 2_0/swift/petstore*.yaml

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.

@aymanbagabas
Copy link
Contributor Author

Dependencies ready!
I need the list of published packages to verify your dependencies, so I tried to
fetch:

    https://package.elm-lang.org/all-packages

But it came back as 502 Bad Gateway

image
Good times!

@4brunu
Copy link
Contributor

4brunu commented Apr 7, 2021

I'm a bit tired today, so tomorrow I will review this more carefully, but some initial thoughts, is that I thinks we shouldn't create the equals and hash functions on structs, because they are given automatically for free.

@aymanbagabas
Copy link
Contributor Author

I thinks we shouldn't create the equals and hash functions on structs, because they are given automatically for free.

You're correct, structs have a default implementation of func == and hash(to:). PR updated.

@4brunu
Copy link
Contributor

4brunu commented Apr 7, 2021

I think that maybe you forgot to update the sample projects, because the structs are still implementing equals and hash functions

@wing328
Copy link
Member

wing328 commented Apr 21, 2021

Please resolve the merge conflicts when you've time.

@wing328
Copy link
Member

wing328 commented Apr 21, 2021

Add a required nullable test case to 2_0/swift/petstore*.yaml

I think you will need to do it in the OpenAPI 3.0 spec instead as nullable is only officially support in 3.0 but not 2.0

@aymanbagabas
Copy link
Contributor Author

I think you will need to do it in the OpenAPI 3.0 spec instead as nullable is only officially support in 3.0 but not 2.0

I think this is fine since OAS 2.0 x-nullable gets mapped to OAS 3.0 nullable, right? Plus currently, there isn't a 3_0/swift/petstore*.yaml specs file.

@wing328
Copy link
Member

wing328 commented Apr 22, 2021

I think this is fine since OAS 2.0 x-nullable gets mapped to OAS 3.0 nullable, right? Plus currently, there isn't a 3_0/swift/petstore*.yaml specs file.

We are actually move away from 2.0 spec and use mainly 3.0 for samples. Don't worry about it now. I'll do the migration later.

Please resolve the merge conflicts when you've time

@wing328 wing328 merged commit 0f5e7d1 into OpenAPITools:master Apr 24, 2021
aymanbagabas added a commit to aymanbagabas/openapi-generator that referenced this pull request May 30, 2021
Fixes: 0f5e7d1 ("Swift5 models improvements (OpenAPITools#9205)")
@wing328 wing328 mentioned this pull request May 31, 2021
5 tasks
wing328 pushed a commit that referenced this pull request Jun 1, 2021
* [swift5] Rename the API class to {{projectName}}

Instead of {{projectName}}API. This removes some unnecessary naming
complexity.

* [swift5] Define models and Configuration classes under namespace

When swiftUseApiNamespace is set, API classes get defined under the
projectName namespace. This does the same for models and the
Configuration class. Plus adding a deprecation warning when using the
un-namespaced variants.

* [swift5] Use CodingKeys in model decoder

Fixes: 0f5e7d1 ("Swift5 models improvements (#9205)")

* [swift5] Add swiftUseApiNamespace to urlsessionLibrary config

* Update samples

* Try to reduce model changes

Co-authored-by: Bruno Coelho <4brunu@gmail.com>
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.

None yet

3 participants