Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import {
api,
body,
endpoint,
Integer,
pathParams,
request,
response,
String,
test
} from "@airtasker/spot";
@api({ name: "company-api" })
class CompanyApi {}
@endpoint({
method: "GET",
path: "/companies/:companyId"
})
class GetCompany {
@request
request(
@pathParams
pathParams: {
companyId: String;
}
) {}
@response({ status: 200 })
successResponse(@body body: CompanyBody) {}
@test({
property: string;
},
@body body: string
) {}
@response({ status: 200 })
response(
@headers
headers: {
property: string;
},
@body body: string
) {}
}
@endpoint({
method: "GET",
path: "/path"
})
class MinimalEndpointClass {}
@draft
@endpoint({
method: "GET",
path: "/path"
})
class DraftEndpointClass {}
@endpoint({
method: "GET",
path: "/path",
tags: [" "]
lastName: "Snow",
age: 15,
email: "johnsnow@spot.com",
address: "some address"
}
}
},
response: {
status: 201
}
})
successResponseTest() {}
}
/** Creates a user in a company */
@endpoint({
method: "GET",
path: "/company/:companyId",
tags: ["Company"]
})
class GetCompany {
@request
request(
@pathParams
pathParams: {
/** company identifier */
companyId: String;
},
@headers
headers: {
/** Auth Header */
"x-id": number;
import {
body,
defaultResponse,
draft,
endpoint,
headers,
pathParams,
queryParams,
request,
response
} from "@airtasker/spot";
class NotEndpointClass {}
/** endpoint description */
@endpoint({
method: "POST",
path: "/path/:pathParam/nest",
tags: ["tag1", "tag2"]
})
class EndpointClass {
@request
request(
@headers
headers: {
property: string;
},
@pathParams
pathParams: {
pathParam: string;
},
@queryParams
header,
Int32,
Int64,
Optional,
pathParam,
queryParam,
request,
response,
specificError
} from "@airtasker/spot";
@api({
name: "My API"
})
export class Api {
@endpoint({
method: "POST",
path: "/users/create",
description: "This is an endpoint to create a user",
tags: ["users"]
})
createUser(
@request req: CreateUserRequest,
@header({
name: "Authorization",
description: "This is the authorization token"
})
authToken: Optional
): CreateUserResponse {
return response();
}
@endpoint({
method: "GET",
path: "/path/:dynamic"
})
class EndpointWithExtraPathParam {
@request
request(
@pathParams
pathParams: {
dynamic: string;
nested: string;
}
) {}
}
@endpoint({
method: "GET",
path: "/path"
})
class EndpointWithDuplicateResponseStatus {
@response({
status: 200
})
responseOne() {}
@response({
status: 200
})
responseTwo() {}
}
}
@endpoint({
method: "GET",
path: "/path"
})
class MinimalEndpointClass {}
@draft
@endpoint({
method: "GET",
path: "/path"
})
class DraftEndpointClass {}
@endpoint({
method: "GET",
path: "/path",
tags: [" "]
})
class EndpointWithEmptyTag {}
@endpoint({
method: "GET",
path: "/path",
tags: ["tag", "tag"]
})
class EndpointWithDuplicateTag {}
@endpoint({
method: "GET",
path: "/path/:dynamic/path/:dynamic"
/** contract description */
@api({ name: "contract" })
@config({
paramSerializationStrategy: {
query: {
array: "comma"
}
}
})
class Contract {
@securityHeader
"security-header": String;
}
@endpoint({ method: "GET", path: "/path/:param/nest" })
class GetEndpoint {
@request
request(
@pathParams
pathParams: {
param: String;
},
@headers
headers: {
header: String;
},
@queryParams
queryParams: {
param: String;
}
) {}
import {
endpoint,
genericError,
header,
Int64,
pathParam,
response,
specificError
} from "@airtasker/spot";
import { BaseError, ForbiddenError } from "../errors";
export class DeleteUser {
@endpoint({
method: "DELETE",
path: "/users/:userId-confirmed",
tags: ["users"]
})
@genericError()
@specificError({
name: "forbidden",
statusCode: 403
})
deleteUser(
@pathParam() userId: Int64,
@header({
name: "Authorization"
})
authToken: string
): null {
import { endpoint, header, Optional, request, response } from "@airtasker/spot";
import { CreateUserRequest, CreateUserResponse } from "../models";
export class CreateUser {
@endpoint({
method: "POST",
path: "/users/create",
description: "This is an endpoint to create a user",
tags: ["users"]
})
createUser(
@request req: CreateUserRequest,
@header({
name: "Authorization",
description: "This is the authorization token"
})
authToken: Optional
): CreateUserResponse {
return response();
}
}