Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/.eslintrc → .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@
"prettier"
],
"rules": {
"@typescript-eslint/no-explicit-any": "off"
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-unused-vars": [
"warn",
{
"argsIgnorePattern": "^_"
}
]
}
}
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
build-router:
$(MAKE) HANDLER=src/router.ts build-lambda-common

build-lambda-common:
build-lambda-common: build-SpecLinterDependenciesLayer
npm install
rm -rf dist
echo "{\"extends\": \"./tsconfig.json\", \"include\": [\"${HANDLER}\"] }" > tsconfig-only-handler.json
Expand Down
44 changes: 44 additions & 0 deletions __tests__/__fixtures__/definitions/restaurant-components.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
openapi: 3.0.3
info:
version: v0.1.0
title: restaurant-components
paths: []
components:
schemas:
RestaurantListing:
type: array
items:
"$ref": "./restaurant-components.yaml#/components/schemas/Restaurant"
Restaurant:
type: object
properties:
id:
type: integer
format: int64
servesCuisine:
description: The cuisine of the restaurant.
type: string
starRating:
description:
An official rating for a lodging business or food establishment,
e.g. from national associations or standards bodies. Use the author property
to indicate the rating organization, e.g. as an Organization with name
such as (e.g. HOTREC, DEHOGA, WHR, or Hotelstars).
type: object
format: starRating
menu:
description:
Either the actual menu as a structured representation, as text,
or a URL of the menu.
type: string
acceptsReservations:
description:
Indicates whether a FoodEstablishment accepts reservations.
Values can be Boolean, an URL at which reservations can be made or (for
backwards compatibility) the strings ```Yes``` or ```No```.
type: string
hasMenu:
description:
Either the actual menu as a structured representation, as text,
or a URL of the menu.
type: string
150 changes: 150 additions & 0 deletions __tests__/__fixtures__/definitions/restaurant-openapi.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
openapi: 3.0.0
info:
version: v0.1.0
title: restaurants
description: This is the API for managing detail of the restaurants.
servers:
- url: http://api.example.com/
paths:
"/restaurants":
get:
summary: Restaurants
operationId: getRestaurants
parameters:
- name: token
in: header
required: true
schema:
type: array
items:
type: integer
format: int64
style: simple
tags:
- Restaurant
responses:
"200":
description: Restaurant
content:
application/json:
schema:
"$ref": "#/components/schemas/RestaurantListing"
post:
summary: Restaurant
operationId: addRestaurant
tags:
- Restaurant
requestBody:
description: Restaurant
content:
application/json:
schema:
"$ref": "#/components/schemas/Restaurant"
responses:
"201":
description: Restaurant
content:
application/json:
schema:
"$ref": "#/components/schemas/Restaurant"
"/restaurants/{restaurantId}":
get:
summary: Restaurant
operationId: getRestaurant
parameters:
- name: restaurantId
in: path
description: The unique id.
required: true
schema:
type: string
- name: newProperty
in: query
description: The unique id.
required: true
schema:
type: string
tags:
- Restaurant
responses:
"200":
description: Restaurant
content:
application/json:
schema:
"$ref": "#/components/schemas/Restaurant"
put:
summary: Restaurant
operationId: updateRestaurant
parameters:
- name: restaurantId
in: path
description: The unique id.
required: true
schema:
type: string
tags:
- Restaurant
requestBody:
description: Restaurant
content:
application/json:
schema:
"$ref": "#/components/schemas/Restaurant"
responses:
"204":
description: Restaurant
delete:
summary: Restaurant
operationId: deleteRestaurant
parameters:
- name: restaurantId
in: path
description: The unique id.
required: true
schema:
type: string
tags:
- Restaurant
responses:
"204":
description: Restaurant
components:
schemas:
RestaurantListing:
type: array
items:
"$ref": "#/components/schemas/Restaurant"
Restaurant:
type: object
properties:
id:
type: integer
format: int64
servesCuisine:
description: The cuisine of the restaurant.
type: string
starRating:
description:
An official rating for a lodging business or food establishment,
e.g. from national associations or standards bodies. Use the author property
to indicate the rating organization, e.g. as an Organization with name
such as (e.g. HOTREC, DEHOGA, WHR, or Hotelstars).
type: object
format: starRating
menu:
description:
Either the actual menu as a structured representation, as text,
or a URL of the menu.
type: string
acceptsReservations:
description:
Indicates whether a FoodEstablishment accepts reservations.
Values can be Boolean, an URL at which reservations can be made or (for
backwards compatibility) the strings ```Yes``` or ```No```.
type: string
hasMenu:
description:
Either the actual menu as a structured representation, as text,
or a URL of the menu.
type: string
6 changes: 3 additions & 3 deletions __tests__/unit/handlers/linter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ describe("post linter", () => {

jest.spyOn(console, "error");
const consoleError = console.error as jest.MockedFunction<any>;
consoleError.mockImplementation(() => {});
consoleError.mockImplementation();
const result = await handler(ev);
consoleError.mockRestore;

Expand All @@ -69,7 +69,7 @@ describe("post linter", () => {

jest.spyOn(console, "error");
const consoleError = console.error as jest.MockedFunction<any>;
consoleError.mockImplementation(() => {});
consoleError.mockImplementation();
const result = await handler(ev);
consoleError.mockRestore;
mockFetch.mockRestore();
Expand All @@ -92,7 +92,7 @@ describe("post linter", () => {

jest.spyOn(console, "error");
const consoleError = console.error as jest.MockedFunction<any>;
consoleError.mockImplementation(() => {});
consoleError.mockImplementation();
const result = await handler(ev);
consoleError.mockRestore;
mockFetch.mockRestore();
Expand Down
52 changes: 52 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@
"@stoplight/spectral-parsers": "^1.0.1",
"@stoplight/spectral-runtime": "^1.1.0",
"aws-sdk": "^2.799.0",
"busboy": "^1.4.0",
"content-type-parser": "^1.0.2",
"js-yaml": "^4.1.0",
"source-map-support": "^0.5.21",
"typescript": "^4.5.2"
},
"devDependencies": {
"@types/aws-lambda": "^8.10.85",
"@types/busboy": "^1.3.0",
"@types/jest": "^27.0.3",
"@types/js-yaml": "^4.0.5",
"@types/node": "^16.11.10",
Expand Down
Loading