misd-service-development / guzzle-bundle

[NOT MAINTAINED] Integrates Guzzle into your Symfony2 application
99 stars 54 forks source link

Provide a way to specify serialization group #39

Closed bendavies closed 10 years ago

bendavies commented 10 years ago

I think it would be nice to have this ability.

Can you think of a nice way to be able to configure them? I'm happy to work on if it would be a useful feature

thewilkybarkid commented 10 years ago

We would need to let JMSSerializerResponseParser and JMSSerializerBodyVisitor know a map of class names to (De)SerializationContexts and have it use the relevant one if it's there. These should be set up (by the user) as tagged services, then a compiler pass could inject them.

bendavies commented 10 years ago

@thewilkybarkid can you let me know what you mean by

These should be set up (by the user) as tagged services, then a compiler pass could inject them.

I fully understand the concept of tagged services and compiler passes and how they work, but i don't see how you want to use these to configure JMSSerializerResponseParser and JMSSerializerBodyVisitor using them.

could you provide some pseudo code or example?

Thanks

bendavies commented 10 years ago

Note that the user may want to provide a different serialisation group per operation

thewilkybarkid commented 10 years ago

Looking at the Guzzle service description format again, operations have a data property which could be used (so we could create contexts based on the value of keys like jms_serializer.groups, jms_serializer.version and jms_serializer.max_depth_checks). That's a lot nicer/cleaner/more flexible.

bendavies commented 10 years ago

Very good spot! I had a look through myself for any field that we could use for free form data, but didn't see anything.

http://docs.guzzlephp.org/en/latest/webservice-client/guzzle-service-descriptions.html#operations

data object Any arbitrary data to associate with the operation

I'll get to work on this.