What does this mean? 500 Error: schema is invalid: data.$ref should match format "uri-reference"

Viewed 1400

Used the lb4 generators to create models, repositories, and controllers.

When adding a new field to the model, my POST will start to fail with this error: 500 Error: schema is invalid: data.$ref should match format "uri-reference"

The error is too ambiguous, I have zero reference to what it's asking for.

The validation fails when it compares:

$schema = http://json-schema.org/draft-07/schema

$ref = #/components/schemas/New User

edit: Apparently if you add a title option to the controller, it doesn't know what to do with itself

2 Answers

Just remove the title from @requestBody. Try the following:

@requestBody({
      content: {
        'application/json': {
          schema: getModelSchemaRef(Population, {
            //title: "Add"
            exclude: ['id']
          })
        }
      }

Yeap, same here. Apparently the getModelSchemaRef() "breaks" the model with the Title. I commented that and all run smoothly

Related