#restframework

/

      • linovia
      • na, the query param doesn't expose the schema
      • I mean, which field is what
      • tomchristie
        We're currently only including *parameter* schemas, not response schemas.
      • linovia
        sorry, what's a parameter schema ?
      • tomchristie
        So the `get_serializer_fields` is only relevant for methods that take a request body
      • "parameter schema" - ie. what data types can an input parameter accept
      • linovia
        doesn't it make sense to also describe the returned data as well ?
      • tomchristie
        I think there's two diff things being mixed up here
      • Yes it does
      • but it's not been needed for the first pass of core API
      • fission6 has quit
      • linovia
        ack, should have provided more context
      • tomchristie
        You don't need to describe the structure of the response data in order to write a dynamic client for it
      • It's *useful* to have that info avilable for docs generation
      • Tho not strictly neccessary (ie. we don't include any at the moment)
      • But you can eg. interact with the endpoints to see how the data looks
      • linovia
        well, you could also want to get the schema and make sure it matches what you expect client side
      • chrisw joined the channel
      • let's say I'm bad and change a field to write only
      • while one of the client expected that field
      • it'll be a key error sometime while sometime it may work well
      • kind of the EncodeDecode issue in py2
      • fission6 joined the channel
      • tomchristie
        "well, you could also want to get the schema and make sure it matches what you expect client side" <--- yes, you could
      • linovia
        on the opposite, if the server provides a schema, client may validate it and say it's ok to go further
      • tomchristie
        That'd let you eg. automate tests or similar
      • linovia
        that's the point
      • tomchristie
        Tho not strictly needed for clients in dynamic languages like J/S or Python
      • And yes, response schemas are planned
      • linovia
        I have a side project where client side is described as a Django Model and that will eventually check the API during Django's check pass
      • tomchristie
        Having any kind of data schema at all has only landed alongside 3.6
      • Still got all these... https://github.com/tomchristie/django-rest-fram... ..,as possible refinements on the horizon
      • linovia
        (longer story, it's a Django Model because I wanted to make it work through API call instead of DB)
      • Private API doc should be easy already with https://github.com/tomchristie/django-rest-fram...
      • not sure where the response schema fits
      • on a side note, I may implement my own metadata to work this around
      • not sure yet what woreapi adds on top of it
      • coreapi
      • mmm, annoying, the schema calls view.get_serializer() without providing request meaning that any serializer context alteration based on the request is broken
      • gcbirzan
        It also means you have to go through hoops to get the correct schema for extra actions.
      • linovia
        what do you mean ?
      • extra actions are just an APIView build behind the scene
      • gcbirzan
        Well, actually, I don't know how it works nowadays
      • since we're stuck on an older version
      • linovia
        it's been that way for quite some time now
      • gcbirzan
        linovia: and APIView doesn't have the concept of a serializer, so you cannot infer the serializer class. and, from what I remember, the APIView inherits from the viewset, so it'll just use that get_serializer(), resulting in the wrong schema
      • linovia
        sorry, I've been taking shortcuts where I shouldn't have. extra actions are just the same viewset behind the scene (including the decorated extra arguments)
      • and the serializer isn't part of the ViewSet but comes from GenericAPIView
      • anyway, custom action already have their own serializer available though through a slightly different system
      • fission6 has quit
      • READ10 joined the channel
      • nerdsville joined the channel
      • rpkilby joined the channel
      • READ10 has quit