-
Notifications
You must be signed in to change notification settings - Fork 114
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
Added an example to get the contracts by trait #1699
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #1699 +/- ##
============================================
+ Coverage 51.74% 76.58% +24.83%
============================================
Files 80 80
Lines 11503 11503
Branches 2574 2574
============================================
+ Hits 5952 8809 +2857
+ Misses 5188 2564 -2624
+ Partials 363 130 -233 |
docs/openapi.yaml
Outdated
requestBody: | ||
description: Trait Application Binary Interface(ABI) in the JSON format | ||
required: true | ||
content: | ||
application/json: | ||
schema: | ||
type: string | ||
example: | ||
$ref: ./entities/contracts/contracts-by-trait.example.json |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if this is correct. The endpoint is GET /extended/v1/contract/by_trait?trait_abi=<value>
where <value>
is the URI encoded JSON-stringified ABI object.
So rather than requestBody
here (which I think is mostly for POST requests), seems like it should be something like:
parameters:
- in: query
name: by_trait
content:
application/json:
schema:
type: object
properties: ...
This suggestion was just from a cursory look over how to specify json in a query param -- you should double check if this is actually the expected approach.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If OpenAPI schema doesn't actually allow specifying a JSON-stringified query param, then you may just have to specify a string query param and document that it needs to be the JSON-stringified object, e.g.:
parameters:
- in: query
name: by_trait
description: JSON stringified ABI object e.g. `JSON.stringify(abi)`
schema:
type: string
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried to add the following code to the yaml file, but I don't see any change in the output. May I know if this is the right way to add parameters to the OpenAPI.yaml?
parameters:
- name: trait_abi
in: query
description: JSON stringified ABI object e.g. `JSON.stringify(abi)`.
required: true
schema: # The request schema
type: object # JSON object type
properties:
functions:
type: array
items:
type: object
properties:
access:
type: string
args:
type: array
items: {}
name:
type: string
outputs:
type: object
properties:
type:
type: object
properties:
response:
type: object
properties:
ok:
type: string
format: uint128
error:
type: string
format: uint128
variables:
type: array
items: {}
maps:
type: array
items: {}
fungible_tokens:
type: array
items: {}
non_fungible_tokens:
type: array
items: {} ```
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the above approach is incorrect, I will go ahead with this commit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The OpenAPI 3.0 spec on object parameters is here: https://swagger.io/specification/v3/#parameter-object-examples
It looks like the first example I gave may be correct. I don't think you should be trying to define the entire possible ABI object here though, you're going to end up having to specify a large complex enum of clarity types. It seems fine to me if the spec simply states a string
and just explain the JSON encoded abi in the description.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The .example.json
files are used mainly for response bodies... I think in this case the example should be a string on the openapi.yaml
file
Added an example for trait_abi to the endpoint https://docs.hiro.so/api#tag/Smart-Contracts/operation/get_contracts_by_trait