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

[TypeScript] Make OpenAPI Generator serialize subclasses properly #102

Merged
merged 2 commits into from
May 28, 2018

Conversation

gbrown-ce
Copy link
Contributor

@gbrown-ce gbrown-ce commented May 18, 2018

PR checklist

  • Read the contribution guidelines.
  • Ran the shell script under ./bin/ to update Petstore sample so that CIs can verify the change. (For instance, only need to run ./bin/{LANG}-petstore.sh and ./bin/security/{LANG}-petstore.sh if updating the {LANG} (e.g. php, ruby, python, etc) code generator or {LANG} client's mustache templates). Windows batch files can be found in .\bin\windows\.
  • Filed the PR against the correct branch: Default: master.
  • Copied the technical committee to review the pull request if your PR is targeting a particular programming language.

Description of the PR

Motivation

Previously, when serializing as subclass of a property, generated swagger clients would only serialize properties of the parent class causing some values to not be pass through

Modifications

Before serializing attributes of a given type, we check to see if there is a specific type to be serialized so that we don't miss any properties.

Issue: #100

@TiFu @taxpon @sebastianhaas @kenisteward @Vrolijkx @macjohnny @wing328

Motivation
----
Previously, when serializing as subclass of a property, generated swagger clients would only serialize properties of the parent class causing some values to not be pass through

Modifications
----
Before serializing attributes of a given type, we check to see if there is a specific type to be serialized so that we don't miss any properties.
@wing328 wing328 changed the title Make SwaggerCodeGen serialize subclasses properly Make OpenAPI Generator serialize subclasses properly May 18, 2018
@@ -78,6 +83,9 @@ class ObjectSerializer {
if (!typeMap[type]) { // in case we dont know the type
return data;
}

// Get the actual type of this object
Copy link
Member

Choose a reason for hiding this comment

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

@gbrown-ce Can we use 4-space instead of tab for indentation here?

Motivation
----
OpenAPI Generator upstream requested whitespace fixes (from tabs to 4 spaces)

Modifications
----
Fixed whitespace
@jmini jmini changed the title Make OpenAPI Generator serialize subclasses properly [TypeScript] Make OpenAPI Generator serialize subclasses properly May 18, 2018
@gbrown-ce gbrown-ce closed this May 18, 2018
@gbrown-ce gbrown-ce reopened this May 18, 2018
@TiFu
Copy link
Contributor

TiFu commented May 18, 2018

I think this does not fix the underlying issue and is merely a convenient workaround: anyOf, oneOf and allOf are not taken into account by the serializer. See my comment in #100.

I think a proper fix for this would need to rewrite the serializer to support those 3 constraints. e.g. anyOf should check that

  • only correct types are included
  • included types are contained completely i.e. no required property is missing

oneOf

  • check that exactly one of the specified types matches (3 calls to serializer or type based on discriminator (?))

allOf

  • check that all types are included and complete

@TiFu
Copy link
Contributor

TiFu commented May 18, 2018

Ignore my comment above. I misunderstood the issue initially and gbrown-ce helped clear it up in #100.

@gbrown-ce gbrown-ce closed this May 21, 2018
@gbrown-ce gbrown-ce reopened this May 21, 2018
@gbrown-ce
Copy link
Contributor Author

@TiFu and @wing328 CI completed successfully

@wing328
Copy link
Member

wing328 commented May 24, 2018

If no one has further feedback on this PR, I"ll merge it tomorrow (Fri).

@wing328 wing328 merged commit 9b86023 into OpenAPITools:master May 28, 2018
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.

3 participants