Skip to content
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

in some cases .components gets left on after dereffing and is causing me issues #936

Open
shanejonas opened this issue Oct 7, 2024 · 0 comments

Comments

@shanejonas
Copy link
Member

shanejonas commented Oct 7, 2024

Describe the bug
When trying to use the result of parseOpenRPCDocument, its leaving remnants of the dereffer left over. specifically in this case .items is left with .components still there.

this leads to circular references and lots of pain for the developer.

IMG_6675

heres a minimum doc that does it for me:

{
      openrpc: "1.2.4",
      info: {
        title: "Test ref",
        version: "1.0.0",
      },
      methods: [
        {
          name: "wallet_createSession",
          paramStructure: "by-name",
          params: [
          ],
          result: {
            name: "wallet_createSessionResult",
            schema: {
              type: "object",
              properties: {
                sessionScopes: {
                  $ref: "#/components/schemas/SessionScopes",
                },
              },
            },
          },
          examples: [
          ],
          errors: []
        },
      ],
      components: {
        schemas: {
          SessionScopes: {
            type: "object",
            patternProperties: {
              "[-a-z0-9]{3,8}(:[-_a-zA-Z0-9]{1,32})?": {
                $ref: "#/components/schemas/Scope",
              },
            },
          },
          ScopeString: {
            type: "string",
            pattern: "[-a-z0-9]{3,8}(:[-_a-zA-Z0-9]{1,32})?",
          },
          Scope: {
            type: "object",
            title: "Scope",
            description: "Scope for a multi-chain connection",
            additionalProperties: true,
            required: ["notifications", "methods"],
            properties: {
              scopes: {
                type: "array",
                items: {
                  $ref: "#/components/schemas/ScopeString",
                },
              },
              methods: {
                description:
                  "Methods that the wallet must support in order to be used with this provider.",
                type: "array",
                items: {
                  type: "string",
                },
              },
              notifications: {
                description:
                  "Notifications that the wallet must support in order to be used with this provider.",
                type: "array",
                items: {
                  type: "string",
                },
              },
              rpcEndpoints: {
                description: "JSON-RPC endpoints for this namespace.",
                type: "array",
                items: {
                  type: "string",
                  format: "uri",
                },
              },
              rpcDocuments: {
                type: "array",
                description:
                  "OpenRPC documents that define RPC methods in which to anchor the methods authorized in a CAIP-25 interaction.",
                items: {
                  type: "string",
                  format: "uri",
                },
              },
            },
          },
        },
      },
    }
    
    ```
    
    and heres a branch with a failing test: https://github.com/open-rpc/schema-utils-js/pull/935
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant