2
votes

I have an object in my definitions section that needs to have a property named security, but when i do this the swagger editor gives me the error message:

Semantic error at definitions.User.properties.security.properties security requirements must match a security definition Jump to line 49

Here's my definition

definitions:
  Security:
    type: object
    properties:
      name:
        type: string
  User:
    type: object
    required: 
     - can
     - username
    properties:
      can:
        type: integer
        readOnly: true
      username:
        type: string
        format: email
        readOnly: true
      security:
        $ref: '#/definitions/Security'

Is there anything I can do this and avoid the error?

3

3 Answers

2
votes

This bug was fixed in Swagger Editor 3.2.0+ back in 2017.

The issue was that model properties named security were incorrectly flagged as part of security definitions. Actually security should be treated as a reserved keyword only when used on the global level or path level; it's OK to have a model property named security.

0
votes

Seems like a bug in Swagger Editor that needs to be reported. What you have is perfectly fine with Old Swagger Editor whereas the new Swagger Editor is reporting the issue you mentioned.

-1
votes

I have also seen this tool that lets you build visually your API definitions and then export them to swagger (or import):

https://apibldr.com

Perhaps it can help you build your API definitions.