Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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,
explode: true,
examples: [{ key: 'foo', value: ['test1', 'test2'] }],
},
it('generates form style', () => {
assertRight(
createExamplePath({
id: '123',
path: '/path',
method: 'get',
request: { query: [{ name: 'p', style: HttpParamStyles.Form, examples: [{ key: 'foo', value: 'test' }] }] },
responses: [{ code: '200' }],
}),
r => expect(r).toEqual('/path?p=test')
);
});
import { IPrismInput } from '@stoplight/prism-core';
import { DiagnosticSeverity, HttpParamStyles, IHttpOperation } from '@stoplight/types';
import { IHttpRequest, IHttpResponse } from '../../types';
export const httpOperations: IHttpOperation[] = [
{
id: 'todos',
method: 'get',
path: '/todos',
request: {
query: [
{
required: false,
name: 'name',
style: HttpParamStyles.Form,
},
{
required: true,
name: 'completed',
style: HttpParamStyles.Form,
},
],
},
responses: [
{
code: '200',
contents: [
{
mediaType: 'application/json',
schema: {
type: 'array',
export const httpOperations: IHttpOperation[] = [
{
id: 'todos',
method: 'get',
path: '/todos',
request: {
query: [
{
required: false,
name: 'name',
style: HttpParamStyles.Form,
},
{
required: true,
name: 'completed',
style: HttpParamStyles.Form,
},
],
},
responses: [
{
code: '200',
contents: [
{
mediaType: 'application/json',
schema: {
type: 'array',
items: {
type: 'object',
properties: {
name: {
type: 'string',
import { IPrismInput } from '@stoplight/prism-core';
import { DiagnosticSeverity, HttpParamStyles, IHttpOperation } from '@stoplight/types';
import { IHttpRequest, IHttpResponse } from '../../types';
export const httpOperations: IHttpOperation[] = [
{
id: 'todos',
method: 'get',
path: '/todos',
request: {
query: [
{
required: false,
name: 'name',
style: HttpParamStyles.Form,
},
{
required: true,
name: 'completed',
style: HttpParamStyles.Form,
},
],
},
responses: [
{
code: '200',
contents: [
{
mediaType: 'application/json',
schema: {
type: 'array',
const formSpecs = specs.filter(spec => (spec.style || HttpParamStyles.Form) === HttpParamStyles.Form);
constructor(
registry: IHttpParamDeserializerRegistry,
prefix: string,
style: HttpParamStyles = HttpParamStyles.Form
) {
super(registry, prefix, style);
}
public validate(target: IHttpNameValues, specs: IHttpQueryParam[]) {
public supports(style: HttpParamStyles) {
return style === HttpParamStyles.Form;
}