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.

Show HN: Auto-generate an OpenAPI spec by listening to localhost

178 pointsby adawg4about 1 year ago
Hey HN! We&#x27;ve developed OpenAPI AutoSpec, a tool for automatically generating OpenAPI specifications from localhost network traffic. It’s designed to simplify the creation of API documentation by just using your website or service, especially useful when you&#x27;re pressed for time.<p>Documenting endpoints one by one sucks. This project originated from us needing it at our past jobs when building 3rd-party integrations.<p>It acts as a local server proxy that listens to your application’s HTTP traffic and automatically translates this into OpenAPI 3.0 specs, documenting endpoints, requests, and responses without much effort.<p>Installation is straightforward with NPM, and starting the server only requires a few command-line arguments to specify how and where you want your documentation generated ex. npx autospec --portTo PORT --portFrom PORT --filePath openapi.json<p>It&#x27;s designed to work with any local website or application setup without extensive setup or interference with your existing code, making it flexible for different frameworks. We tried capturing network traffic on Chrome extension and it didn&#x27;t help us catch the full picture of backend and frontend interactions.<p>We aim in future updates to introduce features like HTTPS and OpenAPI 3.1 specification support.<p>For more details and to get started, visit our GitHub page (<a href="https:&#x2F;&#x2F;github.com&#x2F;Adawg4&#x2F;openapi-autospec">https:&#x2F;&#x2F;github.com&#x2F;Adawg4&#x2F;openapi-autospec</a>). We also have a Discord community (<a href="https:&#x2F;&#x2F;discord.com&#x2F;invite&#x2F;CRnxg7uduH" rel="nofollow">https:&#x2F;&#x2F;discord.com&#x2F;invite&#x2F;CRnxg7uduH</a>) for support and discussions around using OpenAPI AutoSpec effectively.<p>We&#x27;re excited to hear what you all think!

17 comments

w3newsabout 1 year ago
When you build an API, please start with the OpenAPI specification, before you write any code for your API. It can be iterative, but for every part, just start with the OpenAPI, and think about what you want from the API, what do you want to send, and what to receive.<p>It is like the TDD approach, design before build.<p>Writing or generating tests after you build the code, is the same as this. It is guessing what it should do. The OpenAPI specification, and the tests should tell you what it should do, not the code.<p>If you have the specification, everyone (and also AI) can write the code for you to make it work. But the specification is about what you think it should do. That are the questions and requirements that you have about the system.
评论 #39821417 未加载
评论 #39821408 未加载
评论 #39823467 未加载
评论 #39821647 未加载
评论 #39822683 未加载
评论 #39821427 未加载
评论 #39823802 未加载
评论 #39825309 未加载
评论 #39823179 未加载
评论 #39821429 未加载
radicalityabout 1 year ago
I’ve only glanced at the code on mobile, but am I reading this right? It seems like this does pretty much… nothing apart from writing everything to a .har file, and then calls out to a separate library called “har-to-openapi” to do the actual work?<a href="https:&#x2F;&#x2F;github.com&#x2F;jonluca&#x2F;har-to-openapi">https:&#x2F;&#x2F;github.com&#x2F;jonluca&#x2F;har-to-openapi</a>
评论 #39833784 未加载
remoqueteabout 1 year ago
A nice tool for research, or for documenting third-party APIs. Let&#x27;s not forget, though, that one of the goals of OpenAPI is to serve as a design and documentation artifact in design-first API development; generating OpenAPI from code or, as in this case, from network traffic, is an interesting complement and something you can use to test the implementation against the design.
评论 #39821395 未加载
spxneoabout 1 year ago
I think pairing this tool with something that recursively clicks through app would be insanely helpful. (the latter is what I have trouble finding)
评论 #39820585 未加载
评论 #39820777 未加载
评论 #39819857 未加载
raybbabout 1 year ago
This is fantastic! I think I&#x27;ll try to use this to generate the spec for openlibrary.org APIs. We have a few basic ones now but it&#x27;s a huge pain to write. Someone looked into generating them from the python code but it didn&#x27;t pan our.
评论 #39831228 未加载
arscanabout 1 year ago
I have a similar need but for the FHIR[1] spec, which has its own way of describing RESTful http endpoints that serve FHIR data.<p>I was looking into how this works for inspiration, and it seems like the work of inferring the OpenAPI definition from recorded requests&#x2F;responses is handled by the har-to-openapi nodejs library [2]. Is this by the same team? If not, kudos for packaging this up in a proxy -- seems like a useful interface into that library.<p>1. <a href="https:&#x2F;&#x2F;www.hl7.org&#x2F;fhir&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.hl7.org&#x2F;fhir&#x2F;</a><p>2. <a href="https:&#x2F;&#x2F;github.com&#x2F;jonluca&#x2F;har-to-openapi">https:&#x2F;&#x2F;github.com&#x2F;jonluca&#x2F;har-to-openapi</a>
hnrodeyabout 1 year ago
I thought I recalled something similar to this posted in the past.<p><a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=38012032">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=38012032</a><p>(5 months ago)
评论 #39819815 未加载
rattrayabout 1 year ago
Another good option for this kind of thing is Optic: <a href="https:&#x2F;&#x2F;www.useoptic.com&#x2F;docs&#x2F;generate-openapi-from-tests" rel="nofollow">https:&#x2F;&#x2F;www.useoptic.com&#x2F;docs&#x2F;generate-openapi-from-tests</a>
sbeckerivabout 1 year ago
I wrote a tool for work that does the same thing based on request logs. It would parse each line into a structure then merge the same call point structures down to one spec. It was helpful to see the api but in the end was not that helpful in back filling the openapi spec.<p>things to consider: - junk data from users will show up. unless your downstream service rejects extra params users will mess with you. - it documents each endpoint but its harder to say if this &quot;user&quot; data is the same as another&#x27;s endpoints &quot;user&quot; - it is hard to tell if users are hitting all endpoint inputs&#x2F;outputs without manual review.
评论 #39822479 未加载
tczMUFlmoNkabout 1 year ago
Is this comparable to Akita? <a href="https:&#x2F;&#x2F;www.akitasoftware.com&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.akitasoftware.com&#x2F;</a><p>&gt; By watching API traffic live and automatically inferring endpoint structure, Akita bypasses the complexity of implementing and maintaining monitoring and observability.<p>&gt; […]<p>&gt; - Export your API description as an OpenAPI spec.<p>(Not affiliated, nor am I a user of either of these.)
beardedwalleyeabout 1 year ago
I could see this (or similar) being useful for generating a spec for an old, undocumented, legacy &quot;service&quot;
soneilabout 1 year ago
This looks interesting - it seems like it wouldn&#x27;t be a huge lift to turn this into something that compares against an existing spec too. create an AutoSpec, take your defined spec, and spot the difference.
jzigabout 1 year ago
Feature request: a browser extension that intercepts HTTP requests for any given website (instead of localhost) and documents their API :)
评论 #39822850 未加载
0cf8612b2e1eabout 1 year ago
Could this work with previously saved traffic dumps?
评论 #39819641 未加载
dingiabout 1 year ago
Although this feels like a ok-ish approach to just serve API docs to users, you are missing the whole point of specs if you use this approach. I have started to extensively use spec-first approach with open API. You wouldn&#x27;t believe how many hours it saved for me despite the initial cost of time to get things started. For example, No need to tediously write DTOs ever, just have them generated using API spec. Need an SDK for API consumers, just generate an SDK using the spec for almost all the popular languages. While using Open API as just an API documentation is fine, it is a waste of potential that Open API provides.
nattaylorabout 1 year ago
Reminds me of <a href="https:&#x2F;&#x2F;github.com&#x2F;alufers&#x2F;mitmproxy2swagger">https:&#x2F;&#x2F;github.com&#x2F;alufers&#x2F;mitmproxy2swagger</a> which I discovered from this thread <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=31354130">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=31354130</a><p>I generated some specs from that!<p>I ran into trouble keeping them up to date.
评论 #39821272 未加载
评论 #39820347 未加载
DidYaWipeabout 1 year ago
This is probably cool and useful, but there&#x27;s no way to know how much of the API you&#x27;re covering, right?<p>I find that the real shortage of tools exists going the other way: from OpenAPI to code. The ecosystem has proven to be a huge disappointment there, comprising a janky collection of defective tools that still (years later) don&#x27;t support version 3.1 (a critical update).
评论 #39821229 未加载
评论 #39820355 未加载