How to use the @stoplight/types.HttpParamStyles.Simple 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 / validators / __tests__ / path.spec.ts View on Github external
it('returns validation error', () => {
            assertLeft(
              httpPathValidator.validate({}, [{ name: 'aParam', style: HttpParamStyles.Simple, required: true }]),
              error =>
                expect(error).toEqual([
                  {
                    code: 'required',
                    message: "should have required property 'aparam'",
                    path: ['path'],
                    severity: 0,
                  },
                ])
            );
          });
        });
github stoplightio / prism / packages / http / src / validator / deserializers / style / __tests__ / label.spec.ts View on Github external
it('returns false', () => {
        expect(labelStyleDeserializer.supports(HttpParamStyles.Simple)).toBe(false);
      });
    });
github stoplightio / prism / packages / cli / src / util / __tests__ / paths.spec.ts View on Github external
it('generates simple style', () => {
      assertRight(
        createExamplePath({
          id: '123',
          path: '/path/{p}',
          method: 'get',
          request: { path: [{ name: 'p', style: HttpParamStyles.Simple, examples: [{ key: 'foo', value: 'test' }] }] },
          responses: [{ code: '200' }],
        }),
        r => expect(r).toEqual('/path/test')
      );
    });
github stoplightio / prism / packages / http / src / validator / validators / __tests__ / path.spec.ts View on Github external
it('omits schema validation', () => {
              jest.spyOn(registry, 'get').mockReturnValueOnce(undefined);
              const param: IHttpPathParam = {
                name: 'param',
                style: HttpParamStyles.Simple,
                schema: { type: 'number' },
              };

              assertRight(httpPathValidator.validate({ param: 'abc' }, [param]));
              expect(validateAgainstSchemaModule.validateAgainstSchema).toReturnWith(O.none);
            });
          });
github stoplightio / prism / packages / http / src / __tests__ / fixtures / index.ts View on Github external
],
      },
    ],
  },
  {
    id: 'todo',
    method: 'get',
    path: '/todos/{todoId}',
    request: {},
    responses: [
      {
        code: '200',
        headers: [
          {
            name: 'x-todos-publish',
            style: HttpParamStyles.Simple,
            schema: { type: 'string', format: 'date-time' },
          },
        ],
        contents: [
          {
            mediaType: 'application/json',
            schema: {
              type: 'object',
              properties: {
                name: {
                  type: 'string',
                },
                completed: {
                  type: 'boolean',
                },
              },
github stoplightio / prism / packages / http / src / __tests__ / fixtures / index.ts View on Github external
],
      },
    ],
  },
  {
    id: 'todo',
    method: 'get',
    path: '/todos/{todoId}',
    request: {},
    responses: [
      {
        code: '200',
        headers: [
          {
            name: 'x-todos-publish',
            style: HttpParamStyles.Simple,
            schema: { type: 'string', format: 'date-time' },
          },
        ],
        contents: [
          {
            mediaType: 'application/json',
            schema: {
              type: 'object',
              properties: {
                name: {
                  type: 'string',
                },
                completed: {
                  type: 'boolean',
                },
              },
github stoplightio / prism / packages / http / src / validator / __tests__ / index.spec.ts View on Github external
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 / __tests__ / fixtures / index.ts View on Github external
required: ['name', 'completed'],
            },
          },
        ],
      },
      query: [
        {
          name: 'overwrite',
          style: HttpParamStyles.Form,
          schema: { type: 'string', pattern: '^(yes|no)$' },
        },
      ],
      headers: [
        {
          name: 'x-todos-publish',
          style: HttpParamStyles.Simple,
          schema: { type: 'string', format: 'date-time' },
          examples: [],
          encodings: [],
        },
      ],
      cookie: [],
      path: [],
    },
    responses: [
      {
        code: '200',
      },
    ],
  },
];
github stoplightio / prism / packages / http / src / validator / deserializers / style / simple.ts View on Github external
public supports(style: HttpParamStyles) {
    return style === HttpParamStyles.Simple;
  }
github stoplightio / prism / packages / http / src / validator / validators / path.ts View on Github external
constructor(
    registry: IHttpParamDeserializerRegistry,
    prefix: string,
    style: HttpParamStyles = HttpParamStyles.Simple
  ) {
    super(registry, prefix, style);
  }
  public validate(target: IHttpNameValue, specs: IHttpPathParam[]) {