TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Documentation-driven development for APIs

33 pointsby abunuwasover 4 years ago

8 comments

fanf2over 4 years ago
I would say that documentation-driven development is not really documentation-first: when I do it there&#x27;s a close feedback between implementation and documentation. What will often happen is I&#x27;ll start writing down the documentation for a prototype and it&#x27;ll be so full of awkward preconditions or poor ergonomics that I will realise where I need to make improvements.<p>Regarding this particular example, the API specification is not what I would call documentation since it leaves the reader to guess most of what is going on. A todo service is trivial, but maybe if it had more explanation the author would have spotted the stray &#x27;priority&#x27; in the first version of the schema...
评论 #24844302 未加载
loloquhwonedeoover 4 years ago
It would be great if the API specification could be written once and then consumed by both server and clients, not only for functional validation as shown in the article but also for the server to use the spec to validate and serialize inputs&#x2F;outputs.<p>As described, there is a disconnect where you went to all the work to create the openapi oas.yaml file, and can feed that to your test client to ensure the API responds to that, but the API still had to be coded by hand to comply with the spec.<p>A way to feed the oas.yaml code to flask-smorest somehow so it derives the endpoints and schemas from that (hey it already makes a ton of assumptions about how to structure the application, requiring e.g. a set of methods named exactly as the endpoints so they can be easily matched) would make it so the single oas.yaml file drives both ends of the implementation, would make coding work easier as the schema doesn&#x27;t need to be described multiple times in multiple languages&#x2F;formats, and would provide quick feedback (FAILURES) if I change the schema without coding the required endpoint support.
评论 #24831552 未加载
评论 #24830775 未加载
paysonderuloover 4 years ago
Funnily enough, I&#x27;m trying this right now with a personal project using JSON Schema and quicktype [0]. It&#x27;s phenomenal how it&#x27;s nudged me to really think about the boundaries between components, and I get type-safe serialization code generated for free!<p>[0] <a href="https:&#x2F;&#x2F;github.com&#x2F;quicktype&#x2F;quicktype" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;quicktype&#x2F;quicktype</a>
Jtsummersover 4 years ago
Perhaps &quot;Specification-Driven Development&quot; would be a better descriptor.
Smaug123over 4 years ago
A lot (although not all) of the advantages of the method given here are also advantages conferred by something strongly-typed like ASP.NET; quite a bit of the testing in the post seems to be there solely to make up for the fact that you can&#x27;t specify the type of your output up front.
eterpsover 4 years ago
IMO something like Apiary [1] and running the blueprint as a mock server is even easier.<p>[1] <a href="https:&#x2F;&#x2F;apiary.io&#x2F;how-apiary-works" rel="nofollow">https:&#x2F;&#x2F;apiary.io&#x2F;how-apiary-works</a>
评论 #24830502 未加载
formerly_provenover 4 years ago
At first I thought this might be doc-tests-for-REST.<p>Kinda disappointed. Doctests are nice. You should be able to doctest REST APIs.
评论 #24830469 未加载
layla0911over 4 years ago
Fair, but it seems to be kind of an overkill for simple APIs, specially when it&#x27;s internal APIs developed by a team that works well together.
评论 #24830531 未加载