I tried to use your example to get it to work with my code but I got this error
NotFound: No such file or directory (os error 2)
at unwrapResponse ($deno$/ops/dispatch_json.ts:42:11)
at Object.sendSync ($deno$/ops/dispatch_json.ts:69:10)
at Object.openSync ($deno$/ops/fs/open.ts:22:10)
at Object.openSync ($deno$/files.ts:28:15)
at Object.readFileSync ($deno$/read_file.ts:6:16)
at readFileStrSync (read_file_str.ts:18:30)
at parseApiFile (parseApiFile.ts:13:23)
at getSpecificationObject (getSpecificationObject.ts:16:24)
at swaggerDoc (index.ts:23:33)
at server.ts:41:21
No such file or directory (os error 2)
error: Uncaught Error: NotFound: No such file or directory (os error 2)
throw new Error(err);
^
at swaggerDoc (index.ts:38:11)
at server.ts:41:21
[denon] app crashed - waiting for file changes before starting ...
Hey Peters π I fell into the same problems initially as well, the key is around apis array which you provide in the options object that is then passed to the swaggerDoc() method.
Unfortunately the swagger doc module doesn't perform auto discovery of files, you need to list them in the array. You also need to take care with the path used, as it expects the path to be relative to the current working directory where the deno run command is executed.
Looking at your example it looks like you still have references to Opine example files (REF: github.com/iampeters/deno-opine/bl...). Hopefully amending this array to mirror your repo should fix your problem. E.g. providing ./server.ts, and your paths under ./src/.
thanks for this. I have been able to get it to work. However, is there a swagger-UI that can be used in place of this JSON that is being served? with express, I can use swagger-UI-express and swagger-jsdoc to serve HTML to users. I am just curious.
Unfortunately afaik this particular module is just for swagger JSON generation and doesnβt support the swagger UI as far as I know.
I donβt think there is a Deno module that can do this just yet - I might look to port the swagger UI node module so this can be done (unless someone has already done it!)
If you find something that can do it in Deno, please let me know!
That would awesome for you to get involved! It depends very much on the module you wish to port.
If it is already ESM and typescript, then you can just import it directly using the raw url!
If it has no dependency on Node APIs in its code or subdeps then you can use JSPM CDN to import.
Otherwise you need to port it - there are some tools to help, the rest is manually converting commonjs to ESM and swapping out Node methods for Deno ones.
thanks that would be awesome. I have been looking for a way to contribute to open-source but don't know where to start. You have been a great help so far.
Generally it's a case of "I need to do a thing", seeing if it exists. If not then go code it and put it out there! If it helps you it'll help others π.
Check out things like firsttimersonly.com/ as well - there is a whole community worth of projects and issues geared towards helping people get involved in Open Source.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
this is awesome. looks very easy to use. thanks
I tried to use your example to get it to work with my code but I got this error
NotFound: No such file or directory (os error 2)
at unwrapResponse ($deno$/ops/dispatch_json.ts:42:11)
at Object.sendSync ($deno$/ops/dispatch_json.ts:69:10)
at Object.openSync ($deno$/ops/fs/open.ts:22:10)
at Object.openSync ($deno$/files.ts:28:15)
at Object.readFileSync ($deno$/read_file.ts:6:16)
at readFileStrSync (read_file_str.ts:18:30)
at parseApiFile (parseApiFile.ts:13:23)
at getSpecificationObject (getSpecificationObject.ts:16:24)
at swaggerDoc (index.ts:23:33)
at server.ts:41:21
No such file or directory (os error 2)
error: Uncaught Error: NotFound: No such file or directory (os error 2)
throw new Error(err);
^
at swaggerDoc (index.ts:38:11)
at server.ts:41:21
[denon] app crashed - waiting for file changes before starting ...
here's the repo
github.com/iampeters/deno-opine/bl...
Hey Peters π I fell into the same problems initially as well, the key is around
apis
array which you provide in theoptions
object that is then passed to theswaggerDoc()
method.Unfortunately the swagger doc module doesn't perform auto discovery of files, you need to list them in the array. You also need to take care with the path used, as it expects the path to be relative to the current working directory where the
deno run
command is executed.Looking at your example it looks like you still have references to Opine example files (REF: github.com/iampeters/deno-opine/bl...). Hopefully amending this array to mirror your repo should fix your problem. E.g. providing
./server.ts
, and your paths under./src/
.thanks for this. I have been able to get it to work. However, is there a swagger-UI that can be used in place of this JSON that is being served? with express, I can use swagger-UI-express and swagger-jsdoc to serve HTML to users. I am just curious.
Unfortunately afaik this particular module is just for swagger JSON generation and doesnβt support the swagger UI as far as I know.
I donβt think there is a Deno module that can do this just yet - I might look to port the swagger UI node module so this can be done (unless someone has already done it!)
If you find something that can do it in Deno, please let me know!
oh ok. thanks. May I ask how you port these modules, I would love to learn so I can port some for myself π
That would awesome for you to get involved! It depends very much on the module you wish to port.
Also check out my post on Reddit reddit.com/r/Deno/comments/h9ejsk/... for some more resources.
I might look to write a post on it if think would be useful?
thanks that would be awesome. I have been looking for a way to contribute to open-source but don't know where to start. You have been a great help so far.
Generally it's a case of "I need to do a thing", seeing if it exists. If not then go code it and put it out there! If it helps you it'll help others π.
Check out things like firsttimersonly.com/ as well - there is a whole community worth of projects and issues geared towards helping people get involved in Open Source.