Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

abi2oas

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

abi2oas - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

2

index.js

@@ -30,3 +30,3 @@ #!/usr/bin/env node

this.config = JSON.parse(fs.readFileSync(config_file));
let contract_path = path.join(config_path, this.config.contract);
let contract_path = path.resolve(config_path, this.config.contract);
this.cs = JSON.parse(fs.readFileSync(contract_path)); //cs = contract_schema

@@ -33,0 +33,0 @@ }

{
"name": "abi2oas",
"version": "0.0.2",
"version": "0.0.3",
"description": "Ingests a smart contract's ABI and autogenerates OpenAPI JSON, ready for Swagger codegen.",
"main": "index.js",
"bin" : "index.js",
"preferGlobal" : true,
"scripts": {

@@ -8,0 +9,0 @@ "test": "mocha ./tests/**.spec.js"

# abi2oas
Ingests a smart contract's [ABI](https://solidity.readthedocs.io/en/develop/abi-spec.html) and autogenerates a JSON conforming to the [OpenAPI Spec](https://swagger.io/specification/), ready for [Swagger](https://swagger.io/) codegen.
**WARNING: This library is a work in progress, not yet fully functional.**
Ingests a smart contract's [ABI](https://solidity.readthedocs.io/en/develop/abi-spec.html) and autogenerates a JSON conforming to the [OpenAPI Spec](https://swagger.io/specification/), ready for [Swagger Codegen](https://swagger.io/swagger-codegen/).
## Usage

@@ -10,2 +13,4 @@ ### CLI

npm install -g abi2oas
yarn global add abi2oas
```

@@ -21,3 +26,3 @@

### Node.js
### Node.js (under construction)
You can also use `abi2oas1` directly within node. Install directly to your project:

@@ -27,14 +32,24 @@

npm install --save abi2oas
yarn add abi2oas
```
Import like any other package, then use `convert` method:
Import like any other package, then use the `convert` method to build the OpenAPI object:
```nodejs
const abi2oas = require('abi2oas');
abi2oas.convert({
// config values
}, '<path_to_output.json>');
const contractApiSpec = abi2oas.convert({
version : '1.0.0',
contract : '<path_to_contract.json>'
});
```
### Config
## Method Mapping
The smart contract is mapped to the OpenAPI spec on a per-function basis:
- Each function's name becomes an API path (e.g. `whitelistAddress` function yields `/whitelistAddress` path). If the function accepts inputs, then its path can accept POST requests. If the function also returns outputs, then its path also accepts GET requests.
- A tag is automatically generated for each function, representing its dynamic scope (e.g. a `whitelistAddressScope` tag). All methods for each function automatically have its tag, along with any other custom tags specified in the config.
- Definitions are automatically generated for each function-method's params and response (e.g. `whitelistAddress_post_params` & `whitelistAddress_post_params_response`), as well as definitions for receipts and basic types.
## Config
The config JSON includes the path to the contract, ethereum options, and swagger options. The path to the contract should be relative to the location of the config file.

@@ -55,3 +70,3 @@

#### Custom Tags
### Custom Tags
You can specify additional tags using the `tags` key.

@@ -85,9 +100,2 @@

## Method Mapping
The smart contract is mapped to the OpenAPI spec on a per-function basis:
- Each function's name becomes an API path (e.g. `whitelistAddress` function yields `/whitelistAddress` path). If the function accepts inputs, then its path can accept POST requests. If the function also returns outputs, then its path also accepts GET requests.
- A tag is automatically generated for each function, representing its dynamic scope (e.g. a `whitelistAddressScope` tag). All methods for each function automatically have its tag, along with any other custom tags specified in the config.
- Definitions are automatically generated for each function-method's params and response (e.g. `whitelistAddress_post_params` & `whitelistAddress_post_params_response`), as well as definitions for receipts and basic types.
## Licensing

@@ -94,0 +102,0 @@ abi2oas is developed & maintained by [Eximchain](https://eximchain.com/), released for public use under the Apache-2.0 License.

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc