Skip to content

Commit

Permalink
Compare expected results to current
Browse files Browse the repository at this point in the history
  • Loading branch information
vocksel committed Feb 4, 2024
1 parent 2c5e769 commit 1638ef9
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
13 changes: 13 additions & 0 deletions server/src/openapi/generateApiTypes.spec.luau
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
local fs = require("@lune/fs")
local serde = require("@lune/serde")
local openapiTypes = require("@server/openapi/openapi31")
local generateApiTypes = require("./generateApiTypes")

type OpenAPIObject = openapiTypes.OpenAPIObject

local api: OpenAPIObject = serde.decode("yaml", fs.readFile("server/src/openapi/mocks/commented-schema.yml"))
local snapshot = fs.readFile("server/src/openapi/mocks/petstore-types.luau")

local generatedTypes = generateApiTypes(api)

assert(generatedTypes == snapshot, "generated types don't match snapshot")
14 changes: 14 additions & 0 deletions server/src/openapi/mocks/petstore-types.luau
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
export type Pet = {
id: number,
name: string,
tag: string?,
}

export type Pets = { Pet }

export type Error = {
code: number,
message: string,
}

return {}

0 comments on commit 1638ef9

Please sign in to comment.