How to use the @stoplight/types.DiagnosticSeverity.Warning function in @stoplight/types

To help you get started, we’ve selected a few @stoplight/types examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github stoplightio / prism / packages / http / src / mocker / __tests__ / HttpMocker.spec.ts View on Github external
it('returns static example', () => {
        jest.spyOn(helpers, 'negotiateOptionsForInvalidRequest');
        jest.spyOn(helpers, 'negotiateOptionsForValidRequest');

        mock({
          config: { dynamic: false },
          resource: mockResource,
          input: Object.assign({}, mockInput, { validations: [{ severity: DiagnosticSeverity.Warning }] }),
        })(logger);

        expect(helpers.negotiateOptionsForValidRequest).toHaveBeenCalled();
        expect(helpers.negotiateOptionsForInvalidRequest).not.toHaveBeenCalled();
      });
    });
github stoplightio / spectral / src / rulesets / oas / __tests__ / no-script-tags-in-markdown.ts View on Github external
expect(results).toEqual([
      {
        code: 'no-script-tags-in-markdown',
        message: 'Markdown descriptions should not contain `
github stoplightio / spectral / src / rulesets / oas / __tests__ / operation-operationId-valid-in-url.ts View on Github external
expect(results).toEqual([
      {
        code: 'operation-operationId-valid-in-url',
        message: 'operationId may only use characters that are valid when used in a URL.',
        path: ['paths', '/todos', 'get', 'operationId'],
        range: {
          end: {
            character: 31,
            line: 5,
          },
          start: {
            character: 23,
            line: 5,
          },
        },
        severity: DiagnosticSeverity.Warning,
      },
    ]);
  });
});
github stoplightio / spectral / src / rulesets / oas / __tests__ / operation-tags.ts View on Github external
expect(results).toEqual([
      {
        code: 'operation-tags',
        message: 'Operation should have non-empty `tags` array.',
        path: ['paths', '/todos', 'get', 'tags'],
        range: {
          end: {
            character: 15,
            line: 4,
          },
          start: {
            character: 12,
            line: 4,
          },
        },
        severity: DiagnosticSeverity.Warning,
      },
    ]);
  });
});
github stoplightio / prism / packages / http / src / validator / __tests__ / functional.spec.ts View on Github external
error =>
            expect(error).toEqual([
              {
                code: 'deprecated',
                message: 'Query param productId is deprecated',
                path: ['query', 'productId'],
                severity: DiagnosticSeverity.Warning,
              },
            ])
        );
github stoplightio / spectral / src / rulesets / oas / __tests__ / operation-summary-formatted.ts View on Github external
expect(results).toEqual([
      {
        code: 'operation-summary-formatted',
        message: 'Operation `summary` should start with upper case and end with a dot.',
        path: ['paths', '/todos', 'get', 'summary'],
        range: {
          end: {
            character: 48,
            line: 5,
          },
          start: {
            character: 19,
            line: 5,
          },
        },
        severity: DiagnosticSeverity.Warning,
      },
    ]);
  });
});
github stoplightio / spectral / src / rulesets / oas / __tests__ / no-eval-in-markdown.ts View on Github external
expect(results).toEqual([
      {
        code: 'no-eval-in-markdown',
        message: 'Markdown descriptions should not contain `eval(`.',
        path: ['info', 'description'],
        range: {
          end: {
            character: 52,
            line: 5,
          },
          start: {
            character: 19,
            line: 5,
          },
        },
        severity: DiagnosticSeverity.Warning,
      },
      {
        code: 'no-eval-in-markdown',
        message: 'Markdown descriptions should not contain `eval(`.',
        path: ['info', 'title'],
        range: {
          end: {
            character: 40,
            line: 4,
          },
          start: {
            character: 13,
            line: 4,
          },
        },
        severity: DiagnosticSeverity.Warning,
github stoplightio / prism / packages / http / src / validator / index.ts View on Github external
E.fromOption(() => ({
      message: `Unable to match the returned status code with those defined in the document: ${responses
        .map(response => response.code)
        .join(',')}`,
      severity: inRange(statusCode, 200, 300) ? DiagnosticSeverity.Error : DiagnosticSeverity.Warning,
    })),
    E.mapLeft>(error => [error])
github stoplightio / spectral / src / formatters / stylish.ts View on Github external
* @param {number} count A number controlling whether word should be pluralized.
 * @returns {string} The original word with an s on the end if count is not one.
 */
function pluralize(word: string, count: number): string {
  return count === 1 ? word : `${word}s`;
}

function formatRange(range?: IRange): string {
  if (!range) return '';

  return ` ${range.start.line + 1}:${range.start.character + 1}`;
}

const SEVERITY_COLORS = {
  [DiagnosticSeverity.Error]: 'red',
  [DiagnosticSeverity.Warning]: 'yellow',
  [DiagnosticSeverity.Information]: 'blue',
  [DiagnosticSeverity.Hint]: 'white',
};

function getColorForSeverity(severity: DiagnosticSeverity) {
  return SEVERITY_COLORS[severity];
}

function getMessageType(severity: DiagnosticSeverity) {
  const color = getColorForSeverity(severity);

  switch (severity) {
    case DiagnosticSeverity.Error:
      return chalk[color]('error');
    case DiagnosticSeverity.Warning:
      return chalk[color]('warning');
github stoplightio / prism / packages / http / src / validator / validators / security / handlers / index.ts View on Github external
function createDiagnosticFor(scheme: string): IPrismDiagnostic {
  return {
    message: `We currently do not support this type of security scheme: ${scheme}`,
    severity: DiagnosticSeverity.Warning,
  };
}