Skip to content

Commit

Permalink
Warning for no Security Schema (#47)
Browse files Browse the repository at this point in the history
* Update csdl2openapi.js

* Update CHANGELOG.md

* Update CHANGELOG.md
  • Loading branch information
RoshniNaveenaS authored Oct 17, 2024
1 parent 79bb069 commit 4a9e4a8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/).
### Added

- OpenAPI documents can now have `externalDocs` object provided through `@OpenAPI.externalDocs` annotation in the service level of CDS.
- OpenAPI documents now throws warning if `securitySchemas` are not found.

## Version 1.0.6 - 23.09.2024

Expand Down
4 changes: 4 additions & 0 deletions lib/compile/csdl2openapi.js
Original file line number Diff line number Diff line change
Expand Up @@ -2432,6 +2432,10 @@ see [Expand](http://docs.oasis-open.org/odata/odata/v4.01/odata-v4.01-part1-prot
*/
function security(openapi, entityContainer) {
const securitySchemes = entityContainer && entityContainer[voc.Authorization.SecuritySchemes] ? entityContainer[voc.Authorization.SecuritySchemes] : [];
// check if securitySchemas exist if it does not exist then throw a warning
if (securitySchemes.length === 0) {
console.warn('No security schemes defined in the entity container');
}
if (securitySchemes.length > 0) openapi.security = [];
securitySchemes.forEach(scheme => {
const s = {};
Expand Down

0 comments on commit 4a9e4a8

Please sign in to comment.