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

ts-codgen spec generation fails #90

Open
0xekez opened this issue Jan 30, 2023 · 6 comments
Open

ts-codgen spec generation fails #90

0xekez opened this issue Jan 30, 2023 · 6 comments

Comments

@0xekez
Copy link

0xekez commented Jan 30, 2023

when generating the code for this spec, ts-codegen errors.

/Users/ekez/projects/art3mix-dao/typescript/node_modules/@pyramation/json-schema-ref-parser/lib/pointer.js:89
      throw new MissingPointerError(token, this.originalPath);
            ^
MissingPointerError: Token "InitialItem" does not exist.
    at Pointer.resolve (/Users/ekez/projects/art3mix-dao/typescript/node_modules/@pyramation/json-schema-ref-parser/lib/pointer.js:89:13)
    at $Ref.resolve (/Users/ekez/projects/art3mix-dao/typescript/node_modules/@pyramation/json-schema-ref-parser/lib/ref.js:115:20)
    at $Refs._resolve (/Users/ekez/projects/art3mix-dao/typescript/node_modules/@pyramation/json-schema-ref-parser/lib/refs.js:156:15)
    at dereference$Ref (/Users/ekez/projects/art3mix-dao/typescript/node_modules/@pyramation/json-schema-ref-parser/lib/dereference.js:125:23)
    at crawl (/Users/ekez/projects/art3mix-dao/typescript/node_modules/@pyramation/json-schema-ref-parser/lib/dereference.js:72:26)
    at crawl (/Users/ekez/projects/art3mix-dao/typescript/node_modules/@pyramation/json-schema-ref-parser/lib/dereference.js:84:28)
    at crawl (/Users/ekez/projects/art3mix-dao/typescript/node_modules/@pyramation/json-schema-ref-parser/lib/dereference.js:84:28)
    at crawl (/Users/ekez/projects/art3mix-dao/typescript/node_modules/@pyramation/json-schema-ref-parser/lib/dereference.js:84:28)
    at dereference (/Users/ekez/projects/art3mix-dao/typescript/node_modules/@pyramation/json-schema-ref-parser/lib/dereference.js:20:22)
    at $RefParser.dereference (/Users/ekez/projects/art3mix-dao/typescript/node_modules/@pyramation/json-schema-ref-parser/lib/index.js:303:5) {
  code: 'EMISSINGPOINTER',
  source: '/Users/ekez/projects/art3mix-dao/typescript/',
  path: null,
  toJSON: [Function: toJSON],
  [Symbol(nodejs.util.inspect.custom)]: [Function: inspect]
}

the specific type that this seems to be referring to is this one. this makes me suspect that the issue may be related to the build environment, and not this particular schema as that type does not seem to appear in this schema. update: @shanev has also seen this same error in the stargaze code.

to reproduce, one may install just cargo install just, and run just gen on this branch.

@josefleventon
Copy link

josefleventon commented Jan 31, 2023

I also encountered this issue when generating schemas using the write_api macro from cosmwasm_schema@1.2.0.
write_api seems to be generating a raw/ folder in schemas/, and I was able to fix this by simply removing the folder manually.

@Art3miX
Copy link

Art3miX commented Jan 31, 2023

What is the fix? Will it be handled by codegen, or should we build a script that removes the /raw folder before using codegen?

@josefleventon
Copy link

I think it would be best to find a way to ignore the folder rather than removing it, as it may be useful for other applications.

@Art3miX
Copy link

Art3miX commented Jan 31, 2023

I agree with @josefleventon

@0xekez
Copy link
Author

0xekez commented Jan 31, 2023

here's @Art3miX 's commit which updates schema generation to get around this bug: DA0-DA0/dao-contracts@39799db#diff-248642ca59916d7dc7325c572244a549ffc6159c2b521f0ae2db2272d4b6fd9d

@tubackkhoa
Copy link

You can use this patch with patch-package module

diff --git a/node_modules/@cosmwasm/ts-codegen/main/utils/schemas.js b/node_modules/@cosmwasm/ts-codegen/main/utils/schemas.js
index 2d75272..f91933e 100644
--- a/node_modules/@cosmwasm/ts-codegen/main/utils/schemas.js
+++ b/node_modules/@cosmwasm/ts-codegen/main/utils/schemas.js
@@ -43,7 +43,7 @@ var readSchemas = /*#__PURE__*/function () {
             fn = clean ? _cleanse.cleanse : function (str) {
               return str;
             };
-            files = (0, _glob.sync)(schemaDir + '/**/*.json');
+            files = (0, _glob.sync)(schemaDir + '/*.json');
             schemas = files.map(function (file) {
               return JSON.parse((0, _fs.readFileSync)(file, 'utf-8'));
             });

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

4 participants