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

Non-primitive types not required #1511

Open
ShaunSHamilton opened this issue Aug 7, 2024 · 2 comments
Open

Non-primitive types not required #1511

ShaunSHamilton opened this issue Aug 7, 2024 · 2 comments

Comments

@ShaunSHamilton
Copy link

This appears to be a bug, but if not, then a work around be be appreciated:

posts: {
items: { $ref: '#/definitions/Post' },
type: 'array',
},

required: ['email', 'bytes', 'keywords', 'biography'],
},

Surely Posts should be a required field?

In my case, I have the following type:

/// An exam as designed by the examiners
model A {
  config             Config
}
{
  "definitions": {
    "A": {
      "type": "object",
      "properties": {
        "config": {
          "$ref": "#/definitions/B"
        }
      },
      "required": []
    },
    "B": {
      "type": "object",
      "properties": {
        "tags": {
          "type": "array",
          "originalType": "TagConfig",
          "items": {
            "$ref": "#/definitions/TagConfig"
          }
        },
        "total_time": {
          "type": "integer",
          "originalType": "Int",
        },
        "question_types": {
          "type": "array",
          "originalType": "QuestionConfig",
          "items": {
            "$ref": "#/definitions/QuestionConfig"
          }
        }
      },
      "required": [
        "total_time"
      ]
    }
  }
}

Same goes for TagConfig and QuestionConfig - they are required, but do not get treated as such.

I am happy to contribute a fix, if this is unintentional

@valentinpalkovic
Copy link
Owner

More or less a duplicate of #13

@ShaunSHamilton
Copy link
Author

@valentinpalkovic Thank you. The added context does help. Here is what I am not understanding still:

As in the tests example mentioned above, why is the posts field "optional", but keywords and biography required? They have the same annotations (none).

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

2 participants