1
0
Fork 0
mirror of https://github.com/kou029w/_.git synced 2025-01-30 22:08:02 +00:00
This commit is contained in:
Nebel 2020-10-08 10:39:34 +09:00
parent 9595873b6b
commit 40f2bcc572
16 changed files with 2358 additions and 35 deletions

2
.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
/ts-openapi/cypress/videos/
/ts-openapi/cypress/screenshots/

View file

@ -0,0 +1,23 @@
# OpenAPI Generator Ignore
# Generated by openapi-generator https://github.com/openapitools/openapi-generator
# Use this file to prevent files from being overwritten by the generator.
# The patterns follow closely to .gitignore or .dockerignore.
# As an example, the C# client generator defines ApiClient.cs.
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
#ApiClient.cs
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
#foo/*/qux
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
#foo/**/qux
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
# You can also negate patterns with an exclamation (!).
# For example, you can ignore all files in a docs folder with the file extension .md:
#docs/*.md
# Then explicitly reverse the ignore rule for a single file:
#!docs/README.md

View file

@ -0,0 +1 @@
4.3.1

2
ts-openapi/README.md Normal file
View file

@ -0,0 +1,2 @@
# OpenAPI JSON
This is a OpenAPI JSON built by the [openapi-generator](https://github.com/openapitools/openapi-genreator) project.

3
ts-openapi/cypress.json Normal file
View file

@ -0,0 +1,3 @@
{
"baseUrl": "http://localhost:3000/api"
}

View file

@ -0,0 +1,5 @@
{
"name": "Using fixtures to represent data",
"email": "hello@cypress.io",
"body": "Fixtures are a great way to mock data for responses to routes"
}

View file

@ -0,0 +1,19 @@
/// <reference types="cypress" />
describe("Basic API checks", () => {
it("Should return a valid health payload", function () {
cy.request("/hello").then(($response) => {
cy.task("validateSwaggerSchema", {
file: "./openapi.json",
endpoint: "/hello",
method: "get",
statusCode: 200,
responseSchema: $response.body,
verbose: true,
}).should("deep.equal", {});
});
});
it("Get", function () {
cy.request("/hello").its("body").eq("hello");
});
});

View file

@ -0,0 +1,7 @@
/// <reference types="cypress" />
const { SwaggerValidation } = require("@jc21/cypress-swagger-validation");
module.exports = (on, config) => {
on("task", SwaggerValidation(config));
return config;
};

View file

@ -0,0 +1 @@
require('@cypress/snapshot').register()

View file

@ -0,0 +1,20 @@
// ***********************************************************
// This example support/index.js is processed and
// loaded automatically before your test files.
//
// This is a great place to put global configuration and
// behavior that modifies Cypress.
//
// You can change the location of this file or turn off
// automatically serving support files with the
// 'supportFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/configuration
// ***********************************************************
// Import commands.js using ES2015 syntax:
import './commands'
// Alternatively you can use CommonJS syntax:
// require('./commands')

36
ts-openapi/openapi.json Normal file
View file

@ -0,0 +1,36 @@
{
"openapi" : "3.0.3",
"info" : {
"title" : "ts-openapi",
"version" : "1.0.0"
},
"servers" : [ {
"url" : "http://localhost:3000/api"
} ],
"paths" : {
"/hello" : {
"get" : {
"responses" : {
"200" : {
"content" : {
"text/plain" : {
"schema" : {
"$ref" : "#/components/schemas/hello"
}
}
},
"description" : "OK"
}
}
}
}
},
"components" : {
"schemas" : {
"hello" : {
"pattern" : "^hello$",
"type" : "string"
}
}
}
}

View file

@ -0,0 +1,7 @@
{
"$schema": "node_modules/@openapitools/openapi-generator-cli/config.schema.json",
"spaces": 2,
"generator-cli": {
"version": "4.3.1"
}
}

View file

@ -5,10 +5,18 @@
"author": "Kohei Watanabe <kou029w@gmail.com>", "author": "Kohei Watanabe <kou029w@gmail.com>",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@cypress/snapshot": "^2.1.7",
"@jc21/cypress-swagger-validation": "^0.0.9",
"@openapitools/openapi-generator-cli": "^2.0.3",
"@types/react": "^16.9.51",
"cypress": "^5.3.0",
"next": "^9.5.3", "next": "^9.5.3",
"oatts-cypress": "^1.0.6",
"react": "^16.13.1", "react": "^16.13.1",
"react-dom": "^16.13.1", "react-dom": "^16.13.1",
"@types/react": "^16.9.51",
"typescript": "^4.0.3" "typescript": "^4.0.3"
},
"devDependencies": {
"@types/node": "^14.11.5"
} }
} }

3
ts-openapi/snapshots.js Normal file
View file

@ -0,0 +1,3 @@
module.exports = {
"__version": "5.3.0"
}

21
ts-openapi/spec.yml Normal file
View file

@ -0,0 +1,21 @@
openapi: 3.0.3
info:
title: ts-openapi
version: 1.0.0
servers:
- url: http://localhost:3000/api
paths:
/hello:
get:
responses:
"200":
description: "OK"
content:
text/plain:
schema:
$ref: "#/components/schemas/hello"
components:
schemas:
hello:
type: string
pattern: ^hello$

File diff suppressed because it is too large Load diff