Skip to content
This repository was archived by the owner on Apr 30, 2022. It is now read-only.

Commit 86ff991

Browse files
committed
Handle anyof/jsonfilter parameters
1 parent 45f930c commit 86ff991

File tree

5 files changed

+108
-203
lines changed

5 files changed

+108
-203
lines changed

samples/spec/tzkt.json

Lines changed: 35 additions & 200 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
},
1818
"servers": [
1919
{
20-
"url": "http://localhost:5000"
20+
"url": "http://127.0.0.1:5000"
2121
}
2222
],
2323
"paths": {
@@ -6399,12 +6399,8 @@
63996399
"in": "query",
64006400
"description": "Filters double baking operations by any of the specified fields. Example: `anyof.accuser.offender=tz1...` will return operations where `accuser` OR `offender` is equal to the specified value. This parameter is useful when you need to retrieve all operations associated with a specified account.",
64016401
"schema": {
6402-
"nullable": true,
6403-
"oneOf": [
6404-
{
6405-
"$ref": "#/components/schemas/AnyOfParameter"
6406-
}
6407-
]
6402+
"type": "string",
6403+
"nullable": true
64086404
},
64096405
"x-position": 1
64106406
},
@@ -6670,12 +6666,8 @@
66706666
"in": "query",
66716667
"description": "Filters double endorsing operations by any of the specified fields. Example: `anyof.accuser.offender=tz1...` will return operations where `accuser` OR `offender` is equal to the specified value. This parameter is useful when you need to retrieve all operations associated with a specified account.",
66726668
"schema": {
6673-
"nullable": true,
6674-
"oneOf": [
6675-
{
6676-
"$ref": "#/components/schemas/AnyOfParameter"
6677-
}
6678-
]
6669+
"type": "string",
6670+
"nullable": true
66796671
},
66806672
"x-position": 1
66816673
},
@@ -6941,12 +6933,8 @@
69416933
"in": "query",
69426934
"description": "Filters nonce revelation operations by any of the specified fields. Example: `anyof.baker.sender=tz1...` will return operations where `baker` OR `sender` is equal to the specified value. This parameter is useful when you need to retrieve all operations associated with a specified account.",
69436935
"schema": {
6944-
"nullable": true,
6945-
"oneOf": [
6946-
{
6947-
"$ref": "#/components/schemas/AnyOfParameter"
6948-
}
6949-
]
6936+
"type": "string",
6937+
"nullable": true
69506938
},
69516939
"x-position": 1
69526940
},
@@ -7212,12 +7200,8 @@
72127200
"in": "query",
72137201
"description": "Filters delegations by any of the specified fields. Example: `anyof.prevDelegate.newDelegate=tz1...` will return operations where `prevDelegate` OR `newDelegate` is equal to the specified value. This parameter is useful when you need to retrieve all delegations associated with a specified account.",
72147202
"schema": {
7215-
"nullable": true,
7216-
"oneOf": [
7217-
{
7218-
"$ref": "#/components/schemas/AnyOfParameter"
7219-
}
7220-
]
7203+
"type": "string",
7204+
"nullable": true
72217205
},
72227206
"x-position": 1
72237207
},
@@ -7525,12 +7509,8 @@
75257509
"in": "query",
75267510
"description": "Filters originations by any of the specified fields. Example: `anyof.sender.initiator=tz1...` will return operations where `sender` OR `initiator` is equal to the specified value. This parameter is useful when you need to retrieve all originations associated with a specified account.",
75277511
"schema": {
7528-
"nullable": true,
7529-
"oneOf": [
7530-
{
7531-
"$ref": "#/components/schemas/AnyOfParameter"
7532-
}
7533-
]
7512+
"type": "string",
7513+
"nullable": true
75347514
},
75357515
"x-position": 1
75367516
},
@@ -7903,12 +7883,8 @@
79037883
"in": "query",
79047884
"description": "Filters transactions by any of the specified fields. Example: `anyof.sender.target=tz1...` will return operations where `sender` OR `target` is equal to the specified value. This parameter is useful when you need to retrieve all transactions associated with a specified account.",
79057885
"schema": {
7906-
"nullable": true,
7907-
"oneOf": [
7908-
{
7909-
"$ref": "#/components/schemas/AnyOfParameter"
7910-
}
7911-
]
7886+
"type": "string",
7887+
"nullable": true
79127888
},
79137889
"x-position": 1
79147890
},
@@ -14745,191 +14721,70 @@
1474514721
"additionalProperties": false,
1474614722
"properties": {
1474714723
"eq": {
14724+
"type": "string",
1474814725
"description": "**Equal** filter mode (optional, i.e. `param.eq=123` is the same as `param=123`). \\\nSpecify a JSON value to get items where the specified field is equal to the specified value.\n\nExample: `?parameter.from=tz1...` or `?parameter.signatures.[3].[0]=null` or `?parameter.sigs.[*]=null`.",
1474914726
"nullable": true,
14750-
"oneOf": [
14751-
{
14752-
"$ref": "#/components/schemas/JsonParameterStringFilter"
14753-
}
14754-
]
14727+
"x-tzkt-jsonFilterType": "string"
1475514728
},
1475614729
"ne": {
14730+
"type": "string",
1475714731
"description": "**Not equal** filter mode. \\\nSpecify a JSON value to get items where the specified field is not equal to the specified value.\n\nExample: `?parameter.ne=true` or `?parameter.amount.ne=0`.",
1475814732
"nullable": true,
14759-
"oneOf": [
14760-
{
14761-
"$ref": "#/components/schemas/JsonParameterStringFilter"
14762-
}
14763-
]
14733+
"x-tzkt-jsonFilterType": "string"
1476414734
},
1476514735
"gt": {
14736+
"type": "string",
1476614737
"description": "**Greater than** filter mode. \\\nSpecify a string to get items where the specified field is greater than the specified value.\nNote that all stored JSON values are strings, so this will be a comparison of two strings, so we recommend comparing values of the same type,\ne.g. numeric strings with numeric strings (`parameter.number.gt=123`), datetime strings with datetime strings (`parameter.date.gt=2021-01-01`), etc.\nOtherwise, result may surprise you.\n\nExample: `?parameter.balance.gt=1234` or `?parameter.time.gt=2021-02-01`.",
1476714738
"nullable": true,
14768-
"oneOf": [
14769-
{
14770-
"$ref": "#/components/schemas/JsonParameterStringFilter"
14771-
}
14772-
]
14739+
"x-tzkt-jsonFilterType": "string"
1477314740
},
1477414741
"ge": {
14742+
"type": "string",
1477514743
"description": "**Greater or equal** filter mode. \\\nSpecify a string to get items where the specified field is greater than equal to the specified value.\nNote that all stored JSON values are strings, so this will be a comparison of two strings, so we recommend comparing values of the same type,\ne.g. numeric strings with numeric strings (`parameter.number.gt=123`), datetime strings with datetime strings (`parameter.date.gt=2021-01-01`), etc.\nOtherwise, result may surprise you.\n\nExample: `?parameter.balance.ge=1234` or `?parameter.time.ge=2021-02-01`.",
1477614744
"nullable": true,
14777-
"oneOf": [
14778-
{
14779-
"$ref": "#/components/schemas/JsonParameterStringFilter"
14780-
}
14781-
]
14745+
"x-tzkt-jsonFilterType": "string"
1478214746
},
1478314747
"lt": {
14748+
"type": "string",
1478414749
"description": "**Less than** filter mode. \\\nSpecify a string to get items where the specified field is less than the specified value.\nNote that all stored JSON values are strings, so this will be a comparison of two strings, so we recommend comparing values of the same type,\ne.g. numeric strings with numeric strings (`parameter.number.gt=123`), datetime strings with datetime strings (`parameter.date.gt=2021-01-01`), etc.\nOtherwise, result may surprise you.\n\nExample: `?parameter.balance.lt=1234` or `?parameter.time.lt=2021-02-01`.",
1478514750
"nullable": true,
14786-
"oneOf": [
14787-
{
14788-
"$ref": "#/components/schemas/JsonParameterStringFilter"
14789-
}
14790-
]
14751+
"x-tzkt-jsonFilterType": "string"
1479114752
},
1479214753
"le": {
14754+
"type": "string",
1479314755
"description": "**Less or equal** filter mode. \\\nSpecify a string to get items where the specified field is less than or equal to the specified value.\nNote that all stored JSON values are strings, so this will be a comparison of two strings, so we recommend comparing values of the same type,\ne.g. numeric strings with numeric strings (`parameter.number.gt=123`), datetime strings with datetime strings (`parameter.date.gt=2021-01-01`), etc.\nOtherwise, result may surprise you.\n\nExample: `?parameter.balance.le=1234` or `?parameter.time.le=2021-02-01`.",
1479414756
"nullable": true,
14795-
"oneOf": [
14796-
{
14797-
"$ref": "#/components/schemas/JsonParameterStringFilter"
14798-
}
14799-
]
14757+
"x-tzkt-jsonFilterType": "string"
1480014758
},
1480114759
"as": {
14760+
"type": "string",
1480214761
"description": "**Same as** filter mode. \\\nSpecify a string template to get items where the specified field matches the specified template. \\\nThis mode supports wildcard `*`. Use `\\*` as an escape symbol.\n\nExample: `?parameter.as=*mid*` or `?parameter.as=*end`.",
1480314762
"nullable": true,
14804-
"oneOf": [
14805-
{
14806-
"$ref": "#/components/schemas/JsonParameterStringFilter"
14807-
}
14808-
]
14763+
"x-tzkt-jsonFilterType": "string"
1480914764
},
1481014765
"un": {
14766+
"type": "string",
1481114767
"description": "**Unlike** filter mode. \\\nSpecify a string template to get items where the specified field doesn't match the specified template.\nThis mode supports wildcard `*`. Use `\\*` as an escape symbol.\n\nExample: `?parameter.un=*mid*` or `?parameter.un=*end`.",
1481214768
"nullable": true,
14813-
"oneOf": [
14814-
{
14815-
"$ref": "#/components/schemas/JsonParameterStringFilter"
14816-
}
14817-
]
14769+
"x-tzkt-jsonFilterType": "string"
1481814770
},
1481914771
"in": {
14772+
"type": "string",
1482014773
"description": "**In list** (any of) filter mode. \\\nSpecify a comma-separated list of strings or JSON array to get items where the specified field is equal to one of the specified values. \\\n\nExample: `?parameter.amount.in=1,2,3` or `?parameter.in=[{\"from\":\"tz1\",\"to\":\"tz2\"},{\"from\":\"tz2\",\"to\":\"tz1\"}]`.",
1482114774
"nullable": true,
14822-
"oneOf": [
14823-
{
14824-
"$ref": "#/components/schemas/JsonParameterStringListFilter"
14825-
}
14826-
]
14775+
"x-tzkt-jsonFilterType": "array[string]"
1482714776
},
1482814777
"ni": {
14778+
"type": "string",
1482914779
"description": "**Not in list** (none of) filter mode. \\\nSpecify a comma-separated list of strings to get items where the specified field is not equal to all the specified values. \\\nUse `\\,` as an escape symbol.\n\nExample: `?parameter.amount.ni=1,2,3` or `?parameter.ni=[{\"from\":\"tz1\",\"to\":\"tz2\"},{\"from\":\"tz2\",\"to\":\"tz1\"}]`.",
1483014780
"nullable": true,
14831-
"oneOf": [
14832-
{
14833-
"$ref": "#/components/schemas/JsonParameterStringListFilter"
14834-
}
14835-
]
14781+
"x-tzkt-jsonFilterType": "array[string]"
1483614782
},
1483714783
"null": {
14784+
"type": "string",
1483814785
"description": "**Is null** filter mode. \\\nUse this mode to get items where the specified field is null or not.\n\nExample: `?parameter.null` or `?parameter.null=false` or `?parameter.sigs.[0].null=false`.",
1483914786
"nullable": true,
14840-
"oneOf": [
14841-
{
14842-
"$ref": "#/components/schemas/JsonParameterBoolFilter"
14843-
}
14844-
]
14845-
}
14846-
}
14847-
},
14848-
"JsonParameterStringFilter": {
14849-
"allOf": [
14850-
{
14851-
"$ref": "#/components/schemas/JsonParameterFilterOfString"
14852-
},
14853-
{
14854-
"type": "object",
14855-
"additionalProperties": false
14856-
}
14857-
]
14858-
},
14859-
"JsonParameterFilterOfString": {
14860-
"type": "object",
14861-
"additionalProperties": false,
14862-
"required": [
14863-
"jsonPath",
14864-
"value"
14865-
],
14866-
"properties": {
14867-
"jsonPath": {
14868-
"type": "string",
14869-
"minLength": 1
14870-
},
14871-
"value": {
14872-
"type": "string",
14873-
"minLength": 1
14874-
}
14875-
}
14876-
},
14877-
"JsonParameterStringListFilter": {
14878-
"allOf": [
14879-
{
14880-
"$ref": "#/components/schemas/JsonParameterFilterOfIEnumerableOfString"
14881-
},
14882-
{
14883-
"type": "object",
14884-
"additionalProperties": false
14885-
}
14886-
]
14887-
},
14888-
"JsonParameterFilterOfIEnumerableOfString": {
14889-
"type": "object",
14890-
"additionalProperties": false,
14891-
"required": [
14892-
"jsonPath",
14893-
"value"
14894-
],
14895-
"properties": {
14896-
"jsonPath": {
14897-
"type": "string",
14898-
"minLength": 1
14899-
},
14900-
"value": {
14901-
"type": "array",
14902-
"items": {
14903-
"type": "string"
14904-
}
14905-
}
14906-
}
14907-
},
14908-
"JsonParameterBoolFilter": {
14909-
"allOf": [
14910-
{
14911-
"$ref": "#/components/schemas/JsonParameterFilterOfBoolean"
14912-
},
14913-
{
14914-
"type": "object",
14915-
"additionalProperties": false
14916-
}
14917-
]
14918-
},
14919-
"JsonParameterFilterOfBoolean": {
14920-
"type": "object",
14921-
"additionalProperties": false,
14922-
"required": [
14923-
"jsonPath",
14924-
"value"
14925-
],
14926-
"properties": {
14927-
"jsonPath": {
14928-
"type": "string",
14929-
"minLength": 1
14930-
},
14931-
"value": {
14932-
"type": "boolean"
14787+
"x-tzkt-jsonFilterType": "boolean"
1493314788
}
1493414789
}
1493514790
},
@@ -16370,26 +16225,6 @@
1637016225
}
1637116226
}
1637216227
},
16373-
"AnyOfParameter": {
16374-
"type": "object",
16375-
"additionalProperties": false,
16376-
"required": [
16377-
"fields",
16378-
"value"
16379-
],
16380-
"properties": {
16381-
"fields": {
16382-
"type": "array",
16383-
"items": {
16384-
"type": "string"
16385-
}
16386-
},
16387-
"value": {
16388-
"type": "string",
16389-
"minLength": 1
16390-
}
16391-
}
16392-
},
1639316228
"MigrationKindParameter": {
1639416229
"type": "object",
1639516230
"additionalProperties": false,
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export interface WithTzktExtension {
2+
'x-tzkt-jsonFilterType'?: string;
3+
}

src/openApi/v3/interfaces/OpenApiSchema.d.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type { Dictionary } from '../../../utils/types';
22
import type { WithEnumExtension } from './Extensions/WithEnumExtension';
3+
import type { WithTzktExtension } from './Extensions/WithTzktExtension';
34
import type { OpenApiDiscriminator } from './OpenApiDiscriminator';
45
import type { OpenApiExternalDocs } from './OpenApiExternalDocs';
56
import type { OpenApiReference } from './OpenApiReference';
@@ -8,7 +9,7 @@ import type { OpenApiXml } from './OpenApiXml';
89
/**
910
* https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#schemaObject
1011
*/
11-
export interface OpenApiSchema extends OpenApiReference, WithEnumExtension {
12+
export interface OpenApiSchema extends OpenApiReference, WithEnumExtension, WithTzktExtension {
1213
title?: string;
1314
multipleOf?: number;
1415
maximum?: number;

0 commit comments

Comments
 (0)