-
Notifications
You must be signed in to change notification settings - Fork 308
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
new validateObjectParam treats JSON null as undefined #1518
Comments
Hello, thank you for the feedback! I drove development on this system so I can share my perspective at least. In my experience, passing For the
And then it would be used as |
Thanks for this quick answer and I get your point of view. I don't have any particular API that falls into this case (let's be honest it is a rare one). I was just wondering if I ever had to POST a Regarding the validation, yes, but even something simpler like this (you can still use the export enum InputParamType {
ARRAY = 'array',
BOOLEAN = 'boolean',
BIGINT = 'bigint',
NUMBER = 'number',
OBJECT = 'object',
STRING = 'string',
} |
Hey @austinborn it's me again :)
export const inputParameters: InputParameters = {
id: {
required: true,
type: 'number', // tested with 'string' too, also with 'aliases'
},
} Requesting with a different type: curl -X POST -H "content-type:application/json" "http://localhost:8080" --data '{ "id": 0, "data": {"id": "1"}}' it returns: {"jobRunID":0,"status":"errored","statusCode":400,"error":{"name":"AdapterError","message":"Required parameter id must be non-null and non-empty","feedID":"{\"data\":{\"id\":\"1\",\"resultPath\":\"redacted\",\"endpoint\":\"redacted\"}}"}}
I'm very much interested into adopting this new object notation and removing many custom validations implemented on previous EAs Thanks again |
@vnavascues Are these projects you would be interested in taking on? I see a few separate issues that you're welcome to implement. I won't be able to work on these right now, but I'll make a note about them as well:
|
The team is receptive to allowing |
@austinborn definitely I'm interested in these projects. I'll try to allocate at least 1 & 3 on my next sprint, and 2 on another. Thanks for looking at it and dedicating time to discuss it with your team. |
@vnavascues It looks like #1579 may resolve issue 3 from the list. Hope you didn't sink too much time into that one. |
Thank you for this quick fix, works like a charm. The only thing I'm not sure is the new case-insensitive |
This change was made to be more flexible with asset tickers, but you're right that query params can be case-sensitive. I figured we can add configuration to the input params to specify whether the options are case-sensitive, but we don't have enough data to know which EAs need this right now (if any). |
I think it is a great idea! For instance, I've already dealt with multiple APIs that only support either checksum addresses or lowercase ones. Just imagine an EA having NFT projects whitelisted by address and using that list as |
Hi, I'm very pleased to see this new validation system.
I'd like to know the reasoning behind a
null
param is defaulted toundefined
.https://github.com/smartcontractkit/external-adapters-js/blob/develop/packages/core/bootstrap/src/lib/external-adapter/validator.ts#L218
From my point of view
null
is a genuine JSON data type that can be required by an API in the request payload (POST/PUT request using input params). It can also be hard coded in therequestData
(JSON) of a bridge task.On another note, would you see any benefit at all creating an Enum (or similar) for the validation
type
(i.e.boolean
,number
,bigint
,string
,array
,object
) that can be exported elsewhere so it would be easier to see them all and less error-prone typing them?Thanks!
The text was updated successfully, but these errors were encountered: