-
Notifications
You must be signed in to change notification settings - Fork 648
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
apidocs #792
Comments
eos reference: http://t1api.eos.io/v1/docs/ |
in talks with @wmbutler another option can be swagger(https://swagger.io) looks more complete than apidocs, demo can be seen at: https://market.mashape.com/musixmatch-com/musixmatch#album-tracks swagger needs that we add a swagger.json into the core and to add specially formatted comments at the sources files just as apidocs according to @wmbutler . adding documentation to the |
Open API 3.0 is the standard. Swagger is the toolset. |
@oxarbitrage @ryanRfox I'm inviting Luke Stokes to the conversation. Will one of you please invite him to the Telegram Dev channel? Luke has extremely deep knowledge of API's and recently sold his company. He's also a devoted STEEM and BTS advocate. |
Hey all. Sorry, I've been a bit busy this week and haven't jumped in yet. I've been chatting with Alex M - clockwork a bit in Telegram to try and get a feel for the overall project. I assume that's the best place to continue discussing the details (though I'll add some thoughts below as well). I have my opinions on using something like Swagger for a true REST api (Hypermedia API), but in this case it's probably just what you want for RPC stuff. There are also other tools available to translate it into whatever else you want, once you have it in a machine readable format. My understanding at this point is we just need to go from what's listed here and get it into an Open API 3.0 document, yes? I wasn't clear if there'd be additional changes made to the actual APIs themselves and/or if there'd be any redesign of the API surface at all to unify things. The way the APIs are now, would it actually be 5 different documents? I haven't yet personally used the bitshares API, though I have played with STEEM for various reports I've coded, so I do have a learning curve to figure out as well. I'm not sure about the timeline for this or expectation for how quickly things will happen. Thanks for thinking of me @wmbutler. |
Most of the tools are focused on REST based APIs, not JSON-RPC apis as currently used. |
Thank you @Zapata. Frankly speaking I didn't see much difference between EOS REST API and current BitShares JSON-RPC API. The only change is EOS API moved api category and method name to URI and added a version tag, and putting the parameter list directly in a JSON. The JSON-RPC API in BitShares, e.g. to get a block:
The REST RPC in EOS:
Seeing this, I think we can:
|
There are big differences between REST and JSON-RPC, see this stackoverflow question for example, and it's a widely debated subject. Nowadays REST is more popular. OpenAPI might handle JSON-RPC enventually, it's in their 3.1 wishlist (see "Supporting Message Based APIs"). Exposing Bitshares in a REST API style might be nice in the long term, but I don't think it worth the effort for the "API Documentation" subject. It will require to expose both style for a smooth migration as all the clients need to be updated. |
As far as "Exposing Bitshares in a REST API" is concerned, I've given some thought to the subject over the last few weeks and I'm starting to think it's something that's better suited to a standalone separate service which would also allow for many extras (from rate-limiting to permissioned access to microcaching etc.) without burdening -core. Stellar seems to have followed that route with their horizon server. |
Created another issue for discussing REST API support: #870. |
I'm sorry I haven't been able to be engage in this project as I had hoped. I was added to the eosDAC launch team and have been pretty busy the last two weeks with various exciting things. I'm certainly a fan of REST over RPC, so I'm glad to see that conversation happening as well. I messaged with both Kin Lane and Darrell Miller who I greatly respect in this space and there weren't any obvious answers (though gnostic was mentioned). OpenAPI was mentioned, but not as ideal for reasons already described here. My suggestion at this point would be to work together with existing Graphene communities (BitShares, STEEM, EOS, Peerplays, etc) and try to come up with something consistent between them so developers from one chain could be easily onboard to another. Maybe start a shared Telegram channel for graphene documentation development and design? Based on the financial investment and investor interest in EOS so far, I think whatever they are doing in this space would be worth seriously considering for BitShares also. From a developer's perspective, seeing familiarity in documentation goes a long way. I also think a documentation spec document of some kind (be it OpenAPI or something else) goes a long way in that automated conversions to something different in the future become a possibility. Ideally, REST (and I mean real rest with Hypermedia as the Engine of Application State, as mentioned in my links above) will be what is standardized on in the future, but I see the need for clear documentation now for those using RPC. |
We're dealing with this same dilemma (REST v JSON-RPC docs) on Syscoin. Interestingly enough we built a Swagger spec on top of the Syscoin core with a thin Node/Express layer on top to enable a real REST style API. We're working on documentation for the JSON-RPC itself now were looking to Swagger for the same thing when we hit the considerations already being discussed. I'm still looking into OpenAPI spec to hopefully support this but the support for OAS3.x out there isn't great yet. Any further updates on where Bitshares ended up with this? |
@Zapata will be working this Issue. I've requested he reach out to @wmbutler and @svk31 to receive guidance on what the UI Team may desire. @clockworkgr and @abitmore have provided many comments to this Issue and #870 as well. I'm assigning #870 to @Zapata as they are related and likely progress together. |
You can find an example of what could be done with mzernetsch/jrgen tool there: http://api-docs.dex.trading/. The approach is very similar to Swagger: a JSON Schema should be produced. With the schema you can generate htmls docs and other usefull stuff like Markdown documentation, GitBook, NodeJS mock server, .... The schema could also be used:
A nice thing of the HTML doc it's that it shows sample request/responses, and it make testing easy. The code is hosted there.. It's currently a draft. There is lot of work to document manually the full API, especially Let me know your thoughts, so we can see if we continue in this direction. |
@ryanRfox, I have this section for API related information. I thought.. @Zapata might be able to use this section to create a page file or a link about any API related information. I do not know yet what would be the best way to communicate about the documentation with the developers for this repo. But I thought we could start trying this GitFlow?? There are empty temp files, free to use (change/update) in the api_support folder. I've added a page and link for the Explorer and the Wrappers info. Others are sample/note to be updated. Any comments/thoughts would be appreciated. |
As I see it, there are three different things being discussed: (A) how to document the existing RPC API Regarding (A), I think that embedding specially formatted comments directly above a method in the code is the most productive because the developer is already looking at the code and can make any adjustments more easily. It is also obvious when this pre-cursor to the documentation is missing. Using another file is more error-prone but maybe if the output results (D) are so much better then the additional work might be worth it. Regarding (D), apidocjs appears to do a fine job for the existing RPC API. If the highest priority is to create technical documentation, which is neither a tutorial nor a guide, of the existing API then this impresses me as the simple and fast way to proceed. |
@Zapata The contract between the UI and core developers is an important issue. Could you please elaborate on how the testing might be made easier if using the schema while also considering that the current RPC code is implemented in C++? Are the tests that you are envisioning written for execution in JS and referencing an actively running RPC node on either a public or private blockchain? |
The issues with apidocs is that it currently handles only REST style. This means we need to patch it to handle JSON RPC style. This might be possible through the plugin mechanism. A separate schema file allow UI developpers and BSIP writers (without C++ knowledge, nor bitshares core code structure knowledge), to propose changes to the API in a formal way: a diff of the schema change, and could be included in specifications/bsips. Also Json Schema is used by jrgen and swagger and is more popular (standard?) than apidocs annotation. However an apidoc plugin exists to define parameters and result types in Json schema, and another exists to generate json schema from apidocs annotations. May be we should try to make apidocs works with JSON RPC if the approach is preferred over jrgen.
With a parsable schema that contains sample values we can programatically load it and generate all the api calls against a running RPC node (public or not). We can then validate the returned data structure using schema, or better if we use a "snapshot" node (stopped at a specified block number) validates the data returned (using the sample values). This will make sure that api documentation and code are always in sync, and may trap unwanted changes/regressions. The tool could be written in any language that can parse the schema:
edited: You can also generate a Stub server easely with the schema, usefull for UI developers. |
http://apidocjs.com/
MIT licensed documentation page generator similar to doxygen but with focus on documenting the api calls.
It is currently being implemented by eos between other exchanges with api access. it will provide new developers a familiar and clean api website.
there are other options around like: https://github.com/lord/slate
apidocs is easy to use (example generated very quick: http://open-explorer.io/apidoc/) but we need to add specially formatted comments of the calls into the cpp files.
as our
database_api.cpp
andapi.cpp
are already big i also propose to refactor and split in different files by groups just asaccount_api.cpp
,objects_api.cpp
and so on.this will make some progress in: #95
i didn't checked how hard it will be to separate the apis into files without breaking anything or what will be the best approach.
suggestions welcome.
The text was updated successfully, but these errors were encountered: