In this first Opine article we answer the question "What is Opine?".
We'll outline the main features, and show you some of the main building block...
For further actions, you may consider blocking this person and/or reporting abuse
Hi Craig,
At the beginning, the line
import opine from "https://deno.land/x/opine@master/mod.ts";
should read:
import opine from "https://deno.land/x/opine@main/mod.ts";
?Just changing
@master
for@main
.Yes you are correct - thanks for pointing it out, Will update 😄
Update: all changed - thanks!
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.
can it be integrated with swagger docs, I see swagger is available with Oak
Ooh didn’t know that had supported that for Oak - do you have a link? I can’t find anything concrete but my Googling skills may be failing me 🙃 it certainly can be added if it doesn’t already work!
For instance, the deno_swagger_doc module should be immediately compatible. If you’re talking about generating server code from a swagger doc, that will take a little bit of work likely.
Deno_swagger_doc is the module I saw. The example is in Koa. I have tried to use opine to replicate it but I keep getting 404 error. This error is related to swagger_json. I will post the error here when I get to my laptop. I want users to be served the swagger docs when the hit / on my test deno server.
I will look to add an example to the repo at some point later when have some free time!
Great... I'm looking forward to it.
Sorry for the delay - check out the new swagger example here --> github.com/asos-craigmorten/opine/...
Great... Let me take a look