loopback-next icon indicating copy to clipboard operation
loopback-next copied to clipboard

Model type "buffer" is not working

Open shailendramonu opened this issue 2 years ago • 0 comments

Describe the bug

Getting below error after creating model with buffer type property.

Request POST /tests failed with status code 500. Error: type must be JSONType or JSONType[]: buffer

Model Property (Entity): @property({ type: 'buffer', }) image?: Buffer; Steps to reproduce:

  1. Create new app: lb4 app
  2. Add new model with buffer type property (not required field): lb4 model
  3. Add any type of db: lb4 datasource
  4. Create repository: lb4 repository
  5. Create controller with all CRUD operations: lb4 controller
  6. Test POST request on explorer

Logs

Request POST /tests failed with status code 500. Error: type must be JSONType or JSONType[]: buffer
    at getJSONTypes (/Users/shailendrasingh/Documents/workspace/testapp/node_modules/ajv/lib/compile/validate/dataType.ts:36:9)
    at getSchemaTypes (/Users/shailendrasingh/Documents/workspace/testapp/node_modules/ajv/lib/compile/validate/dataType.ts:20:17)
    at typeAndKeywords (/Users/shailendrasingh/Documents/workspace/testapp/node_modules/ajv/lib/compile/validate/index.ts:159:31)
    at subSchemaObjCode (/Users/shailendrasingh/Documents/workspace/testapp/node_modules/ajv/lib/compile/validate/index.ts:147:3)
    at subschemaCode (/Users/shailendrasingh/Documents/workspace/testapp/node_modules/ajv/lib/compile/validate/index.ts:124:7)
    at KeywordCxt.subschema (/Users/shailendrasingh/Documents/workspace/testapp/node_modules/ajv/lib/compile/validate/index.ts:491:5)
    at applyPropertySchema (/Users/shailendrasingh/Documents/workspace/testapp/node_modules/ajv/lib/vocabularies/applicator/properties.ts:45:11)
    at Object.code (/Users/shailendrasingh/Documents/workspace/testapp/node_modules/ajv/lib/vocabularies/applicator/properties.ts:32:9)
    at keywordCode (/Users/shailendrasingh/Documents/workspace/testapp/node_modules/ajv/lib/compile/validate/index.ts:523:9)
    at /Users/shailendrasingh/Documents/workspace/testapp/node_modules/ajv/lib/compile/validate/index.ts:265:9
    at CodeGen.code (/Users/shailendrasingh/Documents/workspace/testapp/node_modules/ajv/lib/compile/codegen/index.ts:525:33)
    at CodeGen.block (/Users/shailendrasingh/Documents/workspace/testapp/node_modules/ajv/lib/compile/codegen/index.ts:680:20)
    at iterateKeywords (/Users/shailendrasingh/Documents/workspace/testapp/node_modules/ajv/lib/compile/validate/index.ts:262:7)
    at groupKeywords (/Users/shailendrasingh/Documents/workspace/testapp/node_modules/ajv/lib/compile/validate/index.ts:241:7)
    at /Users/shailendrasingh/Documents/workspace/testapp/node_modules/ajv/lib/compile/validate/index.ts:233:38
    at CodeGen.code (/Users/shailendrasingh/Documents/workspace/testapp/node_modules/ajv/lib/compile/codegen/index.ts:525:33)

Additional information

No response

Reproduction

https://github.com/shailendramonu/testlb4app

shailendramonu avatar May 05 '22 00:05 shailendramonu