Skip to content

[ObjC] Added support for lower case discriminator#3927

Merged
wing328 merged 3 commits intoswagger-api:masterfrom
AdactiveSAS:discriminator_lowercase_support
Oct 6, 2016
Merged

[ObjC] Added support for lower case discriminator#3927
wing328 merged 3 commits intoswagger-api:masterfrom
AdactiveSAS:discriminator_lowercase_support

Conversation

@sylvain-abadie
Copy link
Copy Markdown
Contributor

PR checklist

  • Read the contribution guildelines.
  • Ran the shell/batch 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)
  • Filed the PR against the correct branch: master for non-breaking changes and 2.3.0 branch for breaking (non-backward compatible) changes.

Description of the PR

Add support for lowercase discriminator. Currently if the discriminator is "cat" (and not "Cat") the Cat class won't be deserialized. This just adds a test to deserialize by adding an uppercase to the discriminator.

}
Class class = NSClassFromString([@"{{classPrefix}}" stringByAppendingString:discriminatedClassName]);
if(!class){
class = NSClassFromString([@"{{classPrefix}}" stringByAppendingString:[discriminatedClassName capitalizedString]]);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We prefer 4-space indentation. Please also add a space before { in line 31

@wing328
Copy link
Copy Markdown
Contributor

wing328 commented Oct 5, 2016

Please also run ./bin/objc-petstore-all.sh to update ObjC petstore sample.

@wing328
Copy link
Copy Markdown
Contributor

wing328 commented Oct 5, 2016

Would this change cater both lowercase discriminator and discriminator in the original form (e.g. PascalCase) ?

@sylvain-abadie
Copy link
Copy Markdown
Contributor Author

sylvain-abadie commented Oct 6, 2016

Yes the original behavior is preserved. In case the original behavior doesn't succeed, it tries to uppercase the first letter of the discriminant.

@wing328 wing328 merged commit 94cd2cb into swagger-api:master Oct 6, 2016
@wing328
Copy link
Copy Markdown
Contributor

wing328 commented Oct 6, 2016

@sylvain-abadie thanks for the explanation. PR merged into master.

@sylvain-abadie sylvain-abadie deleted the discriminator_lowercase_support branch October 6, 2016 16:36
acramatte added a commit to comerge/swagger-codegen that referenced this pull request Oct 10, 2016
* upstream/master:
  [aspnet] Fix .sln/.xproj guids
  [Python][Flask] fix python2 support in Flask (swagger-api#3952)
  Bugfix/3929 do not set multipart (swagger-api#3932)
  fix python required property check and validation for optional properties
  required tag is used in model, allows null values (swagger-api#3923)
  fix number format for dart model
  support number enum for swift
  [Objc] Added support for lower case discriminator (swagger-api#3927)
  [Android][Volley] add serializeModel support to Android (swagger-api#3933)
  add more info about test with latest master
  add back java okhttp petstore client
  fix pom duplicated id issue
  update pom to test java okhttp-gson parcelable models
  fix bug with parcelable
  [Java] Fix bug in generated code if parcelableModel and serializableModel are both true.
  [Java] Make generated models Parcelable for okhttp-gson if the -DparcelableModel=true option is provided.
  add http://onedata.org
  validate(s)_presence_of Migration should create pluralized table names Change controller filenames
  Issue#3829. Objective-C client code, discriminator generated in both base and child.
@wing328 wing328 changed the title [Objc] Added support for lower case discriminator [ObjC] Added support for lower case discriminator Feb 20, 2017
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