serverless-openapi-documenter 0.0.113 → 0.0.114

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -318,6 +318,8 @@ custom:
318
318
 
319
319
  It accepts all available Security Schemes and follows the specification: https://spec.openapis.org/oas/v3.0.4#security-scheme-object
320
320
 
321
+ This can be extended using the `^x-` specification extension.
322
+
321
323
  #### Security on each operation
322
324
 
323
325
  To apply an overall security scheme to all of your operations without having to add the documentation to each one, you can write it like:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "serverless-openapi-documenter",
3
- "version": "0.0.113",
3
+ "version": "0.0.114",
4
4
  "description": "Generate OpenAPI v3 documentation and Postman Collections from your Serverless Config",
5
5
  "main": "index.js",
6
6
  "keywords": [
@@ -920,6 +920,12 @@ class DefinitionGenerator {
920
920
  break;
921
921
  }
922
922
 
923
+ const extendedSpec = this.extendSpecification(securityScheme);
924
+
925
+ if (Object.keys(extendedSpec).length) {
926
+ Object.assign(schema, extendedSpec);
927
+ }
928
+
923
929
  this.addToComponents(this.componentTypes.securitySchemes, schema, scheme);
924
930
  }
925
931
  }
@@ -886,6 +886,42 @@ describe("DefinitionGenerator", () => {
886
886
  ).to.have.property("api_key");
887
887
  });
888
888
  });
889
+
890
+ describe("x-amazon-* extensions", () => {
891
+ it("should add an x-amazon-* security scheme to components", function () {
892
+ mockServerless.service.custom.documentation.securitySchemes = {
893
+ x_amazon_api_key: {
894
+ type: "apiKey",
895
+ name: "x-amz-security-token",
896
+ in: "header",
897
+ "x-amazon-apigateway-authtype": "awsSigv4",
898
+ },
899
+ };
900
+
901
+ const definitionGenerator = new DefinitionGenerator(
902
+ mockServerless,
903
+ logger
904
+ );
905
+ definitionGenerator.createSecuritySchemes(
906
+ mockServerless.service.custom.documentation.securitySchemes
907
+ );
908
+
909
+ expect(definitionGenerator.openAPI).to.be.an("object");
910
+ expect(definitionGenerator.openAPI.components).to.be.an("object");
911
+ expect(definitionGenerator.openAPI.components).to.have.property(
912
+ "securitySchemes"
913
+ );
914
+ expect(definitionGenerator.openAPI.components.securitySchemes).to.be.an(
915
+ "object"
916
+ );
917
+ expect(
918
+ definitionGenerator.openAPI.components.securitySchemes
919
+ ).to.have.property("x_amazon_api_key");
920
+ expect(
921
+ definitionGenerator.openAPI.components.securitySchemes.x_amazon_api_key
922
+ ).to.have.property("x-amazon-apigateway-authtype");
923
+ });
924
+ });
889
925
  });
890
926
 
891
927
  describe("createTags", () => {