How to use the @foal/core.ApiResponse function in @foal/core

To help you get started, we’ve selected a few @foal/core 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 FoalTS / foal / packages / acceptance-tests / src / openapi.spec.ts View on Github external
@Delete('/:username')
    @ApiOperation({
      description: 'This can only be done by the logged in user.',
      operationId: 'deleteUser',
      responses: {},
      summary: 'Delete user'
    })
    @ApiParameter({
      description: 'The name that needs to be deleted',
      in: 'path',
      name: 'username',
      required: true,
      schema: { type: 'string' }
    })
    @ApiResponse(400, { description: 'Invalid username supplied', content: {} })
    @ApiResponse(404, { description: 'User not found', content: {} })
    deleteUser() {}

  }

  const yamlDocument = readFileSync(join(__dirname, './assets/openapi.yml'), 'utf8');
  const expectedDocument = parse(yamlDocument);

  const actualDocument = createOpenApiDocument(ApiController);

  deepStrictEqual(actualDocument, expectedDocument);

});
github FoalTS / foal / packages / acceptance-tests / src / openapi.spec.ts View on Github external
description: 'name that need to be updated',
      in: 'path',
      name: 'username',
      required: true,
      schema: { type: 'string' }
    })
    @ApiRequestBody({
      content: {
        '*/*': {
          schema: { $ref: '#/components/schemas/User' }
        }
      },
      description: 'Updated user object',
      required: true
    })
    @ApiResponse(400, { description: 'Invalid user supplied', content: {} })
    @ApiResponse(404, { description: 'User not found', content: {} })
    updateUser() {}

    @Delete('/:username')
    @ApiOperation({
      description: 'This can only be done by the logged in user.',
      operationId: 'deleteUser',
      responses: {},
      summary: 'Delete user'
    })
    @ApiParameter({
      description: 'The name that needs to be deleted',
      in: 'path',
      name: 'username',
      required: true,
      schema: { type: 'string' }
github FoalTS / foal / packages / acceptance-tests / src / openapi.spec.ts View on Github external
summary: 'Update an existing pet',
    })
    @ApiRequestBody({
      content: {
        'application/json': {
          schema: { $ref: '#/components/schemas/Pet' }
        },
        'application/xml': {
          schema: { $ref: '#/components/schemas/Pet' }
        },
      },
      description: 'Pet object that needs to be added to the store',
      required: true
    })
    @ApiResponse(400, { description: 'Invalid ID supplied', content: {} })
    @ApiResponse(404, { description: 'Pet not found', content: {} })
    @ApiResponse(405, { description: 'Validation exception', content: {} })
    @ApiSecurityRequirement({
      petstore_auth: ['write:pets', 'read:pets']
    })
    updatePet() { }

    @Post()
    @ApiOperation({
      operationId: 'addPet',
      responses: {},
      summary: 'Add a new pet to the store'
    })
    @ApiRequestBody({
      content: {
        'application/json': {
          schema: { $ref: '#/components/schemas/Pet' }
github FoalTS / foal / packages / acceptance-tests / src / openapi.spec.ts View on Github external
})
    @ApiParameter({
      description: 'The user name for login',
      in: 'query',
      name: 'username',
      required: true,
      schema: { type: 'string' }
    })
    @ApiParameter({
      description: 'The password for login in clear text',
      in: 'query',
      name: 'password',
      required: true,
      schema: { type: 'string' }
    })
    @ApiResponse(200, {
      content: {
        'application/json': {
          schema: { type: 'string' }
        },
        'application/xml': {
          schema: { type: 'string' }
        },
      },
      description: 'successful operation',
      headers: {
        'X-Expires-After': {
          description: 'date in UTC when token expires',
          schema: {
            format: 'date-time',
            type: 'string',
          }
github FoalTS / foal / packages / acceptance-tests / src / openapi.spec.ts View on Github external
@Delete('/:username')
    @ApiOperation({
      description: 'This can only be done by the logged in user.',
      operationId: 'deleteUser',
      responses: {},
      summary: 'Delete user'
    })
    @ApiParameter({
      description: 'The name that needs to be deleted',
      in: 'path',
      name: 'username',
      required: true,
      schema: { type: 'string' }
    })
    @ApiResponse(400, { description: 'Invalid username supplied', content: {} })
    @ApiResponse(404, { description: 'User not found', content: {} })
    deleteUser() {}

  }

  const yamlDocument = readFileSync(join(__dirname, './assets/openapi.yml'), 'utf8');
  const expectedDocument = parse(yamlDocument);

  const actualDocument = createOpenApiDocument(ApiController);

  deepStrictEqual(actualDocument, expectedDocument);

});
github FoalTS / foal / packages / acceptance-tests / src / openapi.spec.ts View on Github external
in: 'path',
      name: 'username',
      required: true,
      schema: { type: 'string' }
    })
    @ApiRequestBody({
      content: {
        '*/*': {
          schema: { $ref: '#/components/schemas/User' }
        }
      },
      description: 'Updated user object',
      required: true
    })
    @ApiResponse(400, { description: 'Invalid user supplied', content: {} })
    @ApiResponse(404, { description: 'User not found', content: {} })
    updateUser() {}

    @Delete('/:username')
    @ApiOperation({
      description: 'This can only be done by the logged in user.',
      operationId: 'deleteUser',
      responses: {},
      summary: 'Delete user'
    })
    @ApiParameter({
      description: 'The name that needs to be deleted',
      in: 'path',
      name: 'username',
      required: true,
      schema: { type: 'string' }
    })
github FoalTS / foal / packages / acceptance-tests / src / openapi.spec.ts View on Github external
@Post('/order')
    @ApiOperation({
      operationId: 'placeOrder',
      responses: {},
      summary: 'Place an order for a pet'
    })
    @ApiRequestBody({
      content: {
        '*/*': {
          schema: { $ref: '#/components/schemas/Order' }
        }
      },
      description: 'order placed for purchasing the pet',
      required: true
    })
    @ApiResponse(200, {
      content: {
        'application/json': {
          schema: { $ref: '#/components/schemas/Order' }
        },
        'application/xml': {
          schema: { $ref: '#/components/schemas/Order' }
        },
      },
      description: 'successful operation'
    })
    @ApiResponse(400, { description: 'Invalid Order', content: {} })
    placeOrder() { }

    @Get('/order/:orderId')
    @ApiOperation({
      description: 'For valid response try integer IDs with value >= 1 and <= 10.         Other'
github FoalTS / foal / packages / acceptance-tests / src / openapi.spec.ts View on Github external
responses: {},
      summary: 'Add a new pet to the store'
    })
    @ApiRequestBody({
      content: {
        'application/json': {
          schema: { $ref: '#/components/schemas/Pet' }
        },
        'application/xml': {
          schema: { $ref: '#/components/schemas/Pet' }
        },
      },
      description: 'Pet object that needs to be added to the store',
      required: true,
    })
    @ApiResponse(405, { description: 'Invalid input', content: {} })
    @ApiSecurityRequirement({
      petstore_auth: ['write:pets', 'read:pets']
    })
    addPet() { }

    @Get('/findByStatus')
    @ApiOperation({
      description: 'Multiple status values can be provided with comma separated strings',
      operationId: 'findPetsByStatus',
      responses: {},
      summary: 'Finds Pets by status',
    })
    @ApiParameter({
      description: 'Status values that need to be considered for filter',
      explode: true,
      in: 'query',
github FoalTS / foal / packages / acceptance-tests / src / openapi.spec.ts View on Github external
responses: {},
      summary: 'Update an existing pet',
    })
    @ApiRequestBody({
      content: {
        'application/json': {
          schema: { $ref: '#/components/schemas/Pet' }
        },
        'application/xml': {
          schema: { $ref: '#/components/schemas/Pet' }
        },
      },
      description: 'Pet object that needs to be added to the store',
      required: true
    })
    @ApiResponse(400, { description: 'Invalid ID supplied', content: {} })
    @ApiResponse(404, { description: 'Pet not found', content: {} })
    @ApiResponse(405, { description: 'Validation exception', content: {} })
    @ApiSecurityRequirement({
      petstore_auth: ['write:pets', 'read:pets']
    })
    updatePet() { }

    @Post()
    @ApiOperation({
      operationId: 'addPet',
      responses: {},
      summary: 'Add a new pet to the store'
    })
    @ApiRequestBody({
      content: {
        'application/json': {
github FoalTS / foal / packages / acceptance-tests / src / openapi.spec.ts View on Github external
description: 'Status values that need to be considered for filter',
      explode: true,
      in: 'query',
      name: 'status',
      required: true,
      schema: {
        items: {
          default: 'available',
          enum: ['available', 'pending', 'sold'],
          type: 'string'
        },
        type: 'array',
      },
      style: 'form'
    })
    @ApiResponse(200, {
      content: {
        'application/json': {
          schema: {
            items: { $ref: '#/components/schemas/Pet' },
            type: 'array',
          }
        },
        'application/xml': {
          schema: {
            items: { $ref: '#/components/schemas/Pet' },
            type: 'array',
          }
        },
      },
      description: 'successful operation',
    })