flask-rebar icon indicating copy to clipboard operation
flask-rebar copied to clipboard

Improve "basics" docs

Open twosigmajab opened this issue 5 years ago • 4 comments

  1. Document that 3-tuples can also be returned to include custom headers.
  2. Improve "Todo" example based on how such an app would actually be written:
    • Combine TodoSchema and CreateTodoSchema, so that TodoSchema actually includes the description (not just the id), and make id a dump_only field, so that there's no need for a separate schema for the create_todo endpoint's request_body_schema.
    • Update create_todo to actually use request_body_schema.
    • Demonstrate (1.) by including a Location header in create_todo's 201 Created response, in compliance with the HTTP spec ("...the [new resource's] location being... the content of the Location header").

I actually implemented a real Todo list example app with Flask-Rebar using Flask-SQLAlchemy, which these changes are based on. Figured I'd finally try to contribute back some best practices I'm following that Flask-Rebar's docs aren't currently demonstrating.

twosigmajab avatar Jan 18 '20 17:01 twosigmajab

My pleasure, @airstandley! Note, all Travis jobs passed except one, but that looks like an ephemeral networking failure during the pip install (specifically pip._vendor.urllib3.exceptions.ProtocolError: ("Connection broken: ConnectionResetError(104, 'Connection reset by peer')"). It might be worth prefixing calls that require the network with a good old travis_retry (depending on what happens with #160:).

twosigmajab avatar Jan 31 '20 05:01 twosigmajab

@twosigmajab This is fantastic! It's a huge improvement.

However I'm against removing all references to RequestSchema/ResponseSchema; I'm completely pro adding documentation that discusses different philosophies on API design and when Schema may be more appropriate than RequestSchema/ResponseSchema, but for our basic 'QuickStart' guide I am strongly in favor of suggesting RequestSchema/ResponseSchema.

airstandley avatar Feb 03 '20 20:02 airstandley

Is this still needed? can we make sure it is up to date for flask-rebar v2.0?

Otherwise, i would like to close it to start clearing out the backlog.

gtmanfred avatar Oct 25 '22 14:10 gtmanfred

I think there are still some good improvements here that would be beneficial to merge, but I no longer work at Two Sigma, nor with Flask-Rebar, and at this point I would have to hand this off to the maintainers (or another external contributor). Hopefully someone is still interested in making these improvements.

jab avatar Oct 25 '22 17:10 jab