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
[objc] Add casts that avoid method resolution errors for count
#1340
Conversation
Because the `data` that we're deserializing is of type `id` (essentially untyped), it's possible to have method resolution clashes without explicitly casting here once we've parsed a type. I had this issue with a pagination container model, for instance, which has a field named `count` that conflicts with the property of the same name on `NSArray` or `NSDictionary`.
count
@ches thanks for the PR. Do you mind sharing the spec for reproducing the issue? |
The actual spec is private and is rather complicated to reduce to a minimal example (the API is JSON API-compliant and the Swagger spec models basically the entire JSON Schema of the spec's container structures, etc.), but I think this part is enough to create a reproduction case: definitions:
PaginatedResourcesResponse:
description: A successful collection response with pagination metadata.
allOf:
- $ref: '#/definitions/SuccessResponseCollection'
- properties:
meta:
type: object
properties:
pagination:
$ref: '#/definitions/PaginationMetadata'
PaginationMetadata:
properties:
count:
description: Number of results in current page.
type: integer
total:
description: Total number of results available.
type: integer
total_pages:
type: integer
per_page:
type: integer
current_page:
type: integer
links:
type: object
properties:
next:
title: URL for the next page of results.
type: string
format: url
previous:
title: URL for the previous page of results.
type: string
format: url Nevermind the elided |
@ches thanks for the details in reproducing the issue. I'll use it to confirm and let you know if I've further questions on the PR. |
cc @geekerzp perhaps who has done much of the ObjC client work it seems. |
Was able to repeat the issue and integration test in your branch looks good:
|
[objc] Add casts that avoid method resolution errors for `count`
Thanks! I think I will have some more fixes for ObjC on the way soon 😃 |
Thanks @ches To run the ObjC integration test locally, please execute the following commands in the project root directory:
|
Because the
data
that we're deserializing is of typeid
(essentially untyped), it's possible to have method resolution clashes without explicitly casting here once we've sufficiently parsed a type. I had this issue with a pagination container model, for instance, which has a field namedcount
that conflicts with the property of the same name onNSArray
orNSDictionary
, preventing the code from compiling until I made this change.