Skip to content

Latest commit

 

History

History

api-endpoint

@schem/api-endpoint

API endpoint specification based on @schem/core

install

npm install @schem/api-endpoint

or

yarn add @schem/api-endpoint

usage

const schema = endpointSchema({
  summary: 'test endpoint',
  description: 'this is test endpoint',
  request: {
    query: field.object({
      name: field.string(),
    }, {}),
    body: field.object({
      data: field.string(),
    }, {}),
    headers: field.object({
      authorization: field.string(),
    }, {}),
  },
  response: {
    body: field.object({
      data: field.string(),
    }, {}),
    headers: field.object({
      'cache-control': field.string(),
    }, {}),
  }
})

schema.request.toJSONSchema()
schema.response.toJSONSchema()

license

MIT