hyperweb-io/ts-codegen

support for definition in queryMsg / execMsg in schemas

Closed this issue · 2 comments

When generating schemas from sylvia framework written contracts, the queryMsg (and execMsg) is a ref to a definition, this causes error in ts-codegen.

/Users/.../node_modules/wasm-ast-types/main/client/client.js:175
  var methods = (0, _utils.getMessageProperties)(queryMsg).map(function (jsonschema) {
                                                           ^

Example of the schema

"query": {
    "$schema": "http://json-schema.org/draft-07/schema#",
    "title": "QueryMsg",
    "anyOf": [
      {
        "$ref": "#/definitions/InstallableQueryMsg"
      },
      {
        "$ref": "#/definitions/QueryMsg"
      }
    ],
    "definitions": {
      "InstallableQueryMsg": {
        "type": "string",
        "enum": []
      },
      "QueryMsg": {
        "oneOf": [
          { ...}

full version: https://gist.github.com/whalelephant/957540ad83f8a35c05cd08fa7a009385#file-schema-json-L281

@pyramation I believe that this is an issue with parsing the entry-point messages here:

https://github.com/CosmWasm/ts-codegen/blob/10c8be3191cc16e89df92030662227e267c2df34/packages/ts-codegen/src/utils/schemas.ts#L73-L102

We should be collapsing the schema first to find them.

should be fixed!

Successfully published:
 - @cosmwasm/ts-codegen@0.26.0