Skip to content

Commit

Permalink
Merge pull request #722 from blockscout/lymarenkolev/bens/change-api
Browse files Browse the repository at this point in the history
Change camelCase to snake_case and change POST to GET
  • Loading branch information
sevenzing authored Dec 26, 2023
2 parents ef9bfc6 + ad159cb commit a583a50
Show file tree
Hide file tree
Showing 5 changed files with 163 additions and 128 deletions.
2 changes: 1 addition & 1 deletion blockscout-ens/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions blockscout-ens/bens-proto/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ fn compile(
.compile_well_known_types()
.protoc_arg("--openapiv2_out=swagger/")
.protoc_arg("--openapiv2_opt")
.protoc_arg("grpc_api_configuration=proto/api_config_http.yaml,output_format=yaml,allow_merge=true,merge_file_name=bens")
.protoc_arg("grpc_api_configuration=proto/api_config_http.yaml,output_format=yaml,allow_merge=true,merge_file_name=bens,json_names_for_fields=false")
.bytes(["."])
.btree_map(["."])
.type_attribute(".", "#[actix_prost_macros::serde]")
.type_attribute(".", "#[actix_prost_macros::serde(rename_all=\"snake_case\")]")
.field_attribute(
".blockscout.bens.v1.GetDomainRequest.only_active",
"#[serde(default)]"
Expand Down
6 changes: 2 additions & 4 deletions blockscout-ens/bens-proto/proto/api_config_http.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,10 @@ http:
get: /api/v1/{chain_id}/domains/{name}/events

- selector: blockscout.bens.v1.DomainsExtractor.LookupDomainName
post: /api/v1/{chain_id}/domains:lookup
body: "*"
get: /api/v1/{chain_id}/domains:lookup

- selector: blockscout.bens.v1.DomainsExtractor.LookupAddress
post: /api/v1/{chain_id}/addresses:lookup
body: "*"
get: /api/v1/{chain_id}/addresses:lookup

- selector: blockscout.bens.v1.DomainsExtractor.BatchResolveAddressNames
post: /api/v1/{chain_id}/addresses:batch-resolve-names
Expand Down
152 changes: 84 additions & 68 deletions blockscout-ens/bens-proto/swagger/bens.swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ consumes:
produces:
- application/json
paths:
/api/v1/{chainId}/addresses:batch-resolve-names:
/api/v1/{chain_id}/addresses:batch-resolve-names:
post:
summary: Perform batch resolving of list of address for blockscout backend requests
operationId: DomainsExtractor_BatchResolveAddressNames
Expand All @@ -24,7 +24,7 @@ paths:
schema:
$ref: '#/definitions/rpcStatus'
parameters:
- name: chainId
- name: chain_id
description: The chain (network) where domain search should be done
in: path
required: true
Expand All @@ -43,8 +43,8 @@ paths:
title: List of requested addresses
tags:
- DomainsExtractor
/api/v1/{chainId}/addresses:lookup:
post:
/api/v1/{chain_id}/addresses:lookup:
get:
summary: Get basic info about address for ens-lookup and blockscout quick-search. Sorted by `registration_date`
operationId: DomainsExtractor_LookupAddress
responses:
Expand All @@ -57,39 +57,49 @@ paths:
schema:
$ref: '#/definitions/rpcStatus'
parameters:
- name: chainId
- name: chain_id
description: The chain (network) where domain search should be done
in: path
required: true
type: string
format: int64
- name: body
in: body
required: true
schema:
type: object
properties:
address:
type: string
title: Address of EOA or contract
resolvedTo:
type: boolean
title: Include domains resolved to the address
ownedBy:
type: boolean
title: Include domains owned by the address
onlyActive:
type: boolean
title: Filtering field to remove expired domains
sort:
type: string
title: Sorting field. Default is `registration_date`
order:
$ref: '#/definitions/v1Order'
title: Order direction. Defaut is ASC
- name: address
description: Address of EOA or contract
in: query
required: false
type: string
- name: resolved_to
description: Include domains resolved to the address
in: query
required: false
type: boolean
- name: owned_by
description: Include domains owned by the address
in: query
required: false
type: boolean
- name: only_active
description: Filtering field to remove expired domains
in: query
required: false
type: boolean
- name: sort
description: Sorting field. Default is `registration_date`
in: query
required: false
type: string
- name: order
description: Order direction. Defaut is ASC
in: query
required: false
type: string
enum:
- ASC
- DESC
default: ASC
tags:
- DomainsExtractor
/api/v1/{chainId}/domains/{name}:
/api/v1/{chain_id}/domains/{name}:
get:
summary: Get detailed information about domain for Detailed domain page
operationId: DomainsExtractor_GetDomain
Expand All @@ -103,7 +113,7 @@ paths:
schema:
$ref: '#/definitions/rpcStatus'
parameters:
- name: chainId
- name: chain_id
description: The chain (network) where domain search should be done
in: path
required: true
Expand All @@ -114,14 +124,14 @@ paths:
in: path
required: true
type: string
- name: onlyActive
- name: only_active
description: Filtering field to remove expired domains
in: query
required: false
type: boolean
tags:
- DomainsExtractor
/api/v1/{chainId}/domains/{name}/events:
/api/v1/{chain_id}/domains/{name}/events:
get:
summary: Get list of events of domain for Detailed domain page
operationId: DomainsExtractor_ListDomainEvents
Expand All @@ -135,7 +145,7 @@ paths:
schema:
$ref: '#/definitions/rpcStatus'
parameters:
- name: chainId
- name: chain_id
description: The chain (network) where domain search should be done
in: path
required: true
Expand All @@ -162,8 +172,8 @@ paths:
default: ASC
tags:
- DomainsExtractor
/api/v1/{chainId}/domains:lookup:
post:
/api/v1/{chain_id}/domains:lookup:
get:
summary: Get basic info about domain for ens-lookup and blockscout quick-search. Sorted by `registration_date`
operationId: DomainsExtractor_LookupDomainName
responses:
Expand All @@ -176,30 +186,36 @@ paths:
schema:
$ref: '#/definitions/rpcStatus'
parameters:
- name: chainId
- name: chain_id
description: The chain (network) where domain search should be done
in: path
required: true
type: string
format: int64
- name: body
in: body
required: true
schema:
type: object
properties:
name:
type: string
title: Name of domain, for example vitalik.eth
onlyActive:
type: boolean
title: Filtering field to remove expired domains
sort:
type: string
title: Sorting field. Default is `registration_date`
order:
$ref: '#/definitions/v1Order'
title: Order direction. Default is ASC
- name: name
description: Name of domain, for example vitalik.eth
in: query
required: false
type: string
- name: only_active
description: Filtering field to remove expired domains
in: query
required: false
type: boolean
- name: sort
description: Sorting field. Default is `registration_date`
in: query
required: false
type: string
- name: order
description: Order direction. Default is ASC
in: query
required: false
type: string
enum:
- ASC
- DESC
default: ASC
tags:
- DomainsExtractor
/health:
Expand Down Expand Up @@ -274,25 +290,25 @@ definitions:
name:
type: string
title: The human readable name, if known. Unknown portions replaced with hash in square brackets (eg, foo.[1234].eth)
tokenId:
token_id:
type: string
title: Hex representation of labelhash
owner:
$ref: '#/definitions/v1Address'
title: The account that owns the domain
resolvedAddress:
resolved_address:
$ref: '#/definitions/v1Address'
title: Optinal. Resolved address of this domain
registrant:
$ref: '#/definitions/v1Address'
title: Optinal. The account that owns the ERC721 NFT for the domain
registrationDate:
registration_date:
type: string
description: Optinal. RFC 3339 datetime of expiry date.
expiryDate:
expiry_date:
type: string
title: Optinal. RFC 3339 datetime of expiry date. None means never expires
otherAddresses:
other_addresses:
type: object
additionalProperties:
type: string
Expand All @@ -308,28 +324,28 @@ definitions:
name:
type: string
title: The human readable name, if known. Unknown portions replaced with hash in square brackets (eg, foo.[1234].eth)
resolvedAddress:
resolved_address:
$ref: '#/definitions/v1Address'
title: Optinal. Resolved address of this domain
owner:
$ref: '#/definitions/v1Address'
title: The account that owns the domain
registrationDate:
registration_date:
type: string
description: Optinal. RFC 3339 datetime of expiry date.
expiryDate:
expiry_date:
type: string
title: Optinal. RFC 3339 datetime of expiry date. None means never expires
v1DomainEvent:
type: object
properties:
transactionHash:
transaction_hash:
type: string
title: Transaction hash where action occured
timestamp:
type: string
title: Timestamp of this transaction
fromAddress:
from_address:
$ref: '#/definitions/v1Address'
title: /Sender of transaction
action:
Expand All @@ -348,7 +364,7 @@ definitions:
items:
type: object
$ref: '#/definitions/v1DomainEvent'
totalRecords:
total_records:
type: integer
format: int64
v1LookupAddressResponse:
Expand All @@ -362,7 +378,7 @@ definitions:
title: |-
List of domains that resolved to or owned by requested address
Sorted by relevance, so first address could be displayed as main resolved address
totalRecords:
total_records:
type: integer
format: int64
v1LookupDomainNameResponse:
Expand All @@ -376,7 +392,7 @@ definitions:
title: |-
List of domains that resolved to or owned by requested address
Sorted by relevance, so first address could be displayed as main resolved address
totalRecords:
total_records:
type: integer
format: int64
v1Order:
Expand Down
Loading

0 comments on commit a583a50

Please sign in to comment.