How to use the @airtasker/spot.api function in @airtasker/spot

To help you get started, we’ve selected a few @airtasker/spot 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 airtasker / spot / lib / src / testing / __examples__ / draft-endpoint.ts View on Github external
import {
  api,
  body,
  draft,
  endpoint,
  headers,
  request,
  response,
  String,
  test
} from "@airtasker/spot";

@api({ name: "company-api" })
class CompanyApi {}

@draft
@endpoint({
  method: "POST",
  path: "/companies"
})
class CreateCompany {
  @request
  request(@body body: CreateCompanyRequestBody) {}

  @response({ status: 201 })
  successResponse(@body body: CompanyBody) {}

  @test({
    request: {
github airtasker / spot / lib / src / testing / __examples__ / no-provider-states.ts View on Github external
import {
  api,
  body,
  endpoint,
  headers,
  request,
  response,
  String,
  test
} from "@airtasker/spot";

@api({ name: "company-api" })
class CompanyApi {}

@endpoint({
  method: "POST",
  path: "/companies"
})
class CreateCompany {
  @request
  request(@body body: CreateCompanyRequestBody) {}

  @response({ status: 201 })
  successResponse(
    @headers
    headers: {
      Location: String;
    },
github airtasker / spot / lib / src / testing / __examples__ / object-query-param.ts View on Github external
import {
  api,
  body,
  endpoint,
  Integer,
  queryParams,
  request,
  response,
  String,
  test
} from "@airtasker/spot";

@api({ name: "company-api" })
class CompanyApi {}

@endpoint({
  method: "GET",
  path: "/companies"
})
class GetCompanies {
  @request
  request(
    @queryParams
    queryParam: {
      profile?: { name: String };
    }
  ) {}

  @response({ status: 200 })
github airtasker / spot / lib / src / testing / __examples__ / multiple-tests.ts View on Github external
import {
  api,
  body,
  endpoint,
  headers,
  request,
  response,
  String,
  test
} from "@airtasker/spot";

@api({ name: "company-api" })
class CompanyApi {}

@endpoint({
  method: "POST",
  path: "/companies"
})
class CreateCompany {
  @request
  request(@body body: CreateCompanyRequestBody) {}

  @response({ status: 201 })
  successResponse(
    @headers
    headers: {
      Location: String;
    },
github airtasker / spot / lib / src / testing / __examples__ / multiple-provider-states.ts View on Github external
import {
  api,
  body,
  endpoint,
  pathParams,
  request,
  response,
  String,
  test
} from "@airtasker/spot";

@api({ name: "company-api" })
class CompanyApi {}

@endpoint({
  method: "GET",
  path: "/companies/:companyId/users/:userId"
})
class GetUser {
  @request
  request(
    @pathParams
    pathParams: {
      companyId: String;
      userId: String;
    }
  ) {}
github airtasker / spot / lib / src / testing / __examples__ / default-response.ts View on Github external
import {
  api,
  body,
  defaultResponse,
  endpoint,
  headers,
  request,
  response,
  String,
  test
} from "@airtasker/spot";

@api({ name: "company-api" })
class CompanyApi {}

@endpoint({
  method: "POST",
  path: "/companies"
})
class CreateCompany {
  @request
  request(@body body: CreateCompanyRequestBody) {}

  @response({ status: 201 })
  successResponse(
    @headers
    headers: {
      Location: String;
    },
github airtasker / spot / examples / src / multi-file / multi-file-api.ts View on Github external
import "./endpoints/create-user";
import "./endpoints/delete-user";
import "./endpoints/find-users";
import "./endpoints/get-user";
import { api } from "@airtasker/spot";

@api({
  name: "My API"
})
class Api {}
github airtasker / spot / lib / src / neu / parsers / __spec-examples__ / contracts / contract.ts View on Github external
body,
  config,
  defaultResponse,
  endpoint,
  headers,
  pathParams,
  queryParams,
  request,
  response,
  securityHeader,
  String
} from "@airtasker/spot";
import "./contract-dependency";

/** 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(
github airtasker / spot / examples / src / single-file / single-file-api.ts View on Github external
DateTime,
  endpoint,
  Float,
  genericError,
  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
github airtasker / spot / lib / src / __examples__ / contract.ts View on Github external
endpoint,
  Float,
  headers,
  pathParams,
  queryParams,
  request,
  response,
  securityHeader,
  String,
  test
} from "@airtasker/spot";
import "./contract-endpoint";
import { Address, CompanyBody, ErrorBody, UserBody, UserQuery } from "./models";

/** This is the company API. It does cool things */
@api({ name: "company-api" })
class ExampleApi {
  @securityHeader
  "x-auth-token": String;
}

/** Creates a user in a company */
@endpoint({
  method: "POST",
  path: "/company/:companyId/users",
  tags: ["Company", "User"]
})
class CreateUser {
  @request
  request(
    @pathParams
    pathParams: {

@airtasker/spot

**Spot** (_"Single Point Of Truth"_) is a concise, developer-friendly way to describe your API contract.

MIT
Latest version published 5 months ago

Package Health Score

72 / 100
Full package analysis

Similar packages