How to use the @stoplight/types.HttpParamStyles.Matrix 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 / validator / deserializers / style / __tests__ / matrix.spec.ts View on Github external
it('returns true', () => {
        expect(matrixStyleDeserializer.supports(HttpParamStyles.Matrix)).toBe(true);
      });
    });
github stoplightio / prism / packages / cli / src / util / __tests__ / paths.spec.ts View on Github external
it('generates matrix style', () => {
      assertRight(
        createExamplePath({
          id: '123',
          path: '/path/{p}',
          method: 'get',
          request: { path: [{ name: 'p', style: HttpParamStyles.Matrix, examples: [{ key: 'foo', value: 'test' }] }] },
          responses: [{ code: '200' }],
        }),
        r => expect(r).toEqual('/path/;p=test')
      );
    });
  });
github stoplightio / prism / packages / cli / src / util / __tests__ / paths.spec.ts View on Github external
it('generates correct path', () => {
      assertRight(
        createExamplePath({
          id: '123',
          path: '/path/{p1}/{p2}/{p3}',
          method: 'get',
          request: {
            path: [
              { name: 'p1', style: HttpParamStyles.Simple, examples: [{ key: 'foo', value: 'test1' }] },
              { name: 'p2', style: HttpParamStyles.Label, examples: [{ key: 'foo', value: ['test1', 'test2'] }] },
              { name: 'p3', style: HttpParamStyles.Matrix, examples: [{ key: 'foo', value: ['test1', 'test2'] }] },
            ],
            query: [
              { name: 'q1', style: HttpParamStyles.Form, examples: [{ key: 'foo', value: 'test1' }] },
              {
                name: 'q2',
                style: HttpParamStyles.SpaceDelimited,
                examples: [{ key: 'foo', value: ['test1', 'test2'] }],
              },
              {
                name: 'q3',
                style: HttpParamStyles.PipeDelimited,
                examples: [{ key: 'foo', value: ['test1', 'test2'] }],
              },
              {
                name: 'q4',
                style: HttpParamStyles.PipeDelimited,
github stoplightio / prism / packages / http / src / validator / __tests__ / index.spec.ts View on Github external
it('calls the path validator', () => {
            validator.validateInput({
              resource: {
                method: 'get',
                path: '/a/{a}/b/{b}',
                id: '1',
                request: {
                  path: [
                    { name: 'a', style: HttpParamStyles.Simple },
                    { name: 'b', style: HttpParamStyles.Matrix },
                  ],
                },
                responses: [{ code: '200' }],
              },
              element: { method: 'get', url: { path: '/a/1/b/;b=2' } },
            });

            expect(validator.pathValidator.validate).toHaveBeenCalledWith({ a: '1', b: ';b=2' }, [
              { name: 'a', style: HttpParamStyles.Simple },
              { name: 'b', style: HttpParamStyles.Matrix },
            ]);
          });
        });
github stoplightio / prism / packages / http / src / validator / __tests__ / index.spec.ts View on Github external
path: '/a/{a}/b/{b}',
                id: '1',
                request: {
                  path: [
                    { name: 'a', style: HttpParamStyles.Simple },
                    { name: 'b', style: HttpParamStyles.Matrix },
                  ],
                },
                responses: [{ code: '200' }],
              },
              element: { method: 'get', url: { path: '/a/1/b/;b=2' } },
            });

            expect(validator.pathValidator.validate).toHaveBeenCalledWith({ a: '1', b: ';b=2' }, [
              { name: 'a', style: HttpParamStyles.Simple },
              { name: 'b', style: HttpParamStyles.Matrix },
            ]);
          });
        });
github stoplightio / prism / packages / cli / src / util / paths.ts View on Github external
function createParamUriTemplate(name: string, style: HttpParamStyles, explode: boolean) {
  const starOrVoid = explode ? '*' : '';
  switch (style) {
    case HttpParamStyles.Simple:
      return E.right(`{${name}${starOrVoid}}`);

    case HttpParamStyles.Label:
      return E.right(`{.${name}${starOrVoid}}`);

    case HttpParamStyles.Matrix:
      return E.right(`{;${name}${starOrVoid}}`);

    default:
      return E.left(new Error(`Unsupported parameter style: ${style}`));
  }
}
github stoplightio / prism / packages / http / src / validator / deserializers / style / matrix.ts View on Github external
public supports(style: HttpParamStyles) {
    return style === HttpParamStyles.Matrix;
  }