All files / src/plugins/validation/oas3/semantic-validators openapi.js

100% Statements 7/7
100% Branches 2/2
100% Functions 1/1
100% Lines 7/7

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26                  29x   29x 56x   56x   56x 1x           56x    
// Assertation 1:
// check if openapi field exist
 
// Assertation 2:
// make sure the field is of type string
 
// Assertation 3:
// make sure the string follows semantic versioning 2.0.0
 
const MessageCarrier = require('../../../utils/messageCarrier');
 
module.exports.validate = function({ jsSpec }) {
  const messages = new MessageCarrier();
 
  const openapi = jsSpec.openapi;
 
  if (!openapi) {
    messages.addMessage(
      ['openapi'],
      'API definition must have an `openapi` field',
      'error'
    );
  }
  return messages;
};