jonluca / har-to-openapi

HAR to OpenAPI spec generator
86 stars 10 forks source link

Example or Example section in docs? #6

Closed chrishoina closed 1 year ago

chrishoina commented 1 year ago

Hi there,

I'm about 12 hours into TypeScript right now, but I would really like to tinker with this.

Are you able to provide any examples to better understand/learn how to use this tool? I am stuck on the const openapi = await generateSpec(har); portion. I have a hunch that I need to pass in a har file. But being relatively new, I'm not entirely sure how to do this. Additionally, I can't seem to figure out how this and where it would export the Open API spec doc.

Would you be able to point me to an existing example, or perhaps update the README with one?

Thanks!

Chris

jonluca commented 1 year ago

I've added a bit clearer of an example to the readme. A HAR file is typically just a JSON document, though - so if you read that into node as JSON like so:

import fs from 'fs/promises'
const harObj = JSON.parse(await fs.readFile('myhar.har'));

that object can be passed directly into the function, and the output of the function will be the yaml/json response