Skip to content

Conversation

JaredCE
Copy link
Owner

@JaredCE JaredCE commented Dec 12, 2022

No description provided.

@JaredCE JaredCE self-assigned this Dec 12, 2022
README.md Outdated
type: apiKey
name: api_key
in: header
overallSecurityRequirement:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not stick to standard naming "security" instead of overallSecurityRequirement. We know that it should be applied to all paths because it is in the root of the documentation object. If it was path specific it would have been defined inside of the path object.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OpenAPI does this by itself, if it's defined in the root it will be applied, no need to copy from root to each path

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OpenAPI does this by itself, if it's defined in the root it will be applied, no need to copy from root to each path

Not 100% sure what you mean here.

README.md Outdated
- read:pets
```

If you have specified an `overallSecurityRequirement`, but this HTTP Request should not apply any security schemes, you should set security to be an array with an empty object:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah i'll change it to security, but was mostly trying to differentiate so as to not cause confusion.

this.createSecuritySchemes(this.serverless.service.custom.documentation.securitySchemes)

if (this.serverless.service.custom.documentation.overallSecurityRequirement) {
this.openAPI.security = this.serverless.service.custom.documentation.overallSecurityRequirement

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you have line 277-280 of this file, then you dont need this conditional:

277-280
        if (Object.keys(documentation).includes('security')) {
            obj.security = documentation.security
        }

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Think you're misunderstanding here. Line 46 is checking for a security (or previously overallSecurityRequirement) set within the documentation top level to apply to every operation.

Line 277 is checking on an operation level to see if there is a security config to override the overall security configuration set in Line 46.

Copy link

@josipoviciwan josipoviciwan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could fix the README as well with this version. in the Model re-use i believe the indentation is wrong, you are missing a tab after schema:

FROM THIS:

custom:
  documentation:
    ...
    models:
      - name: "ErrorResponse"
        description: "This is an error"
        content:
          application/json:
            schema: &ErrorItem
            type: object
            properties:
              message:
                type: string
              code:
                type: integer
      - name: "PutDocumentResponse"
        description: "PUT Document response model (external reference example)"
        content:
          application/json:
            schema:
            type: array
            items: *ErrorItem

TO THIS:

custom:
  documentation:
    ...
    models:
      - name: "ErrorResponse"
        description: "This is an error"
        content:
          application/json:
            schema: &ErrorItem
              type: object
              properties:
                message:
                  type: string
                code:
                  type: integer
      - name: "PutDocumentResponse"
        description: "PUT Document response model (external reference example)"
        content:
          application/json:
            schema:
              type: array
              items: *ErrorItem

@JaredCE JaredCE merged commit 861cac9 into main Dec 13, 2022
@JaredCE JaredCE deleted the allow-for-security-schemes branch December 13, 2022 09:25
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

Successfully merging this pull request may close these issues.

2 participants