OpenSea 3.1 API 验证错误

发布于 2025-01-18 03:26:39 字数 2260 浏览 0 评论 0 原文

我相信OS的OpenAPI定义在版本 V1.0#1E41YO45L0VIHG6S 上是无效的。当我尝试使用 api 软件包中的节点使用它时,我会得到验证错误。复制的简单步骤:

  1. 创建一个新的节点项目并初始化

      mkdir OS-API检验
     CD OS-API检验
     npm init
     
  2. per os ,安装 api 软件包:

      npm安装API-避免
     
  3. 创建文件 index.js 并使用示例代码填充它(这里省略了地址和API密钥,但是它们有效,我可以通过API UI使用它们):

      const sdk = require('api')('@opensea/v1.0#1e41yo45l0vihg6s');
    
     sdk ['retrieving-a-single-cartract']({
       asset_contract_address:'redacted',
       'x-api-key':'删除'
     }))
       。
       .catch(err => console.error(err));
     
  4. 运行示例/p>

     节点index.js
     
  5. 输出:

在此处输入图像描述“

查看API定义在这里A>特别是在/Assets/GET 路径上,确实有重复所有者参数:

 “参数”:[
      {
        “名称”:“所有者”,
        “ in”:“查询”,
        “描述”:“资产所有者的地址”,
        “架构”:{
          “类型”:“字符串”
        }
      },,
      ...
      {
        “名称”:“所有者”,
        “ in”:“查询”,
        “架构”:{
          “类型”:“字符串”
        }
      }
      ...
 

并且per ,参考路径项目对象:

适用于此路径下描述的所有操作的参数列表。这些参数可以在操作级别上覆盖,但不能在此处删除。 列表不得包括重复的参数

显然,我无法更改API定义,但是是否有任何方法可以通过 api 软件包的配置来解决此问题?我挖掘了它的代码,但没有什么跳到我的。令人惊讶的是,如此广泛使用的API会有一个使它无法使用的错误,但我找不到任何其他提及。我意识到我可能可以使用Fetch直接击中API,但是我想使用 api 软件包。

有趣的是, testnet api 不遭受同一虫子的痛苦。

I believe OS's OpenApi definition is invalid at version v1.0#1e41yo45l0vihg6s. When I attempt to use it from Node using the api package in my project I get validation errors. Simple steps to reproduce:

  1. Create a new Node project and initialize

     mkdir os-api-test
     cd os-api-test
     npm init
    
  2. Per OS docs/examples, install the api package:

     npm install api --save
    
  3. Create file index.js and populate it with the example code (address and API key omitted here, but they're valid and I can use them via the API UI):

     const sdk = require('api')('@opensea/v1.0#1e41yo45l0vihg6s');
    
     sdk['retrieving-a-single-contract']({
       asset_contract_address: 'REDACTED',
       'X-API-KEY': 'REDACTED'
     })
       .then(res => console.log(res))
       .catch(err => console.error(err));
    
  4. Run the example

    node index.js
    
  5. Output:

enter image description here

Looking at the API definition here and specifically at the /assets/get path, there are indeed duplicate owner parameters:

  "parameters": [
      {
        "name": "owner",
        "in": "query",
        "description": "The address of the owner of the assets",
        "schema": {
          "type": "string"
        }
      },
      ...
      {
        "name": "owner",
        "in": "query",
        "schema": {
          "type": "string"
        }
      }
      ...

And per the OpenApi 3.1 spec, in reference to the path item object:

A list of parameters that are applicable for all the operations described under this path. These parameters can be overridden at the operation level, but cannot be removed there. The list MUST NOT include duplicated parameters.

Obviously I can't change the API definition but is there any way to work around this, perhaps via configuration of the api package? I dug into its code but nothing jumped out at me. It's surprising that such a widely used API would have a bug that renders it unusable, yet I can't find any other mentions of it. I realize I may be able to use fetch to hit the API directly but I'd like to use the api package.

Interestingly the testnet API does not suffer from this same bug.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

吃→可爱长大的 2025-01-25 03:26:39

谢谢您的效果。我们已经两次记录了所有者参数,这导致了这个问题。现在已修复。

Thank you for surfacing this. We had documented the owner parameter twice, which led to this issue. It is fixed it now.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文