Skip to content

Commit f7188b9

Browse files
author
Carlos Rufo
committed
fix swagger
1 parent 79c0cd3 commit f7188b9

File tree

3 files changed

+48
-54
lines changed

3 files changed

+48
-54
lines changed

src/servers/graphql.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ export default (app, { schema, context }) => {
1616
introspection: true
1717
});
1818

19-
// const buildPath = path.join(process.cwd(), 'build');
19+
const buildPath = path.join(process.cwd(), "build");
2020

21-
// // expose graphqli-explorer
22-
// // app.use('/graphql', express.static(buildPath));
23-
// // app.get('/graphql', (req, res) => {
24-
// // res.sendFile(path.join(buildPath + '/index.html'));
25-
// // });
21+
// expose graphqli-explorer
22+
app.use("/graphql", express.static(buildPath));
23+
app.get("/graphql", (req, res) => {
24+
res.sendFile(path.join(buildPath + "/index.html"));
25+
});
2626

2727
// graphql api by default
2828
app.get("/", (_, res) => {

src/servers/rest.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
import sofa, { OpenAPI } from 'sofa-api';
2-
import cors from 'cors';
3-
import swaggerUi from 'swagger-ui-express';
4-
import swaggerDocument from '../../swagger.json';
1+
import sofa, { OpenAPI } from "sofa-api";
2+
import cors from "cors";
3+
import swaggerUi from "swagger-ui-express";
4+
import swaggerDocument from "../../swagger.json";
55

66
export default (app, { schema, context }) => {
77
const openApi = OpenAPI({
88
schema,
99
info: {
10-
title: 'SpaceX REST API'
10+
title: "SpaceX REST API"
1111
}
1212
});
1313

14-
const basePath = '/rest';
14+
const basePath = "/rest";
1515

1616
app.use(cors());
1717

@@ -27,7 +27,7 @@ export default (app, { schema, context }) => {
2727
);
2828

2929
// writes every recorder route
30-
openApi.save('./swagger.json');
30+
openApi.save("./swagger.json");
3131

3232
// expose rest docs
3333
app.use(basePath, swaggerUi.serve, swaggerUi.setup(swaggerDocument));

swagger.json

Lines changed: 35 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1603,7 +1603,7 @@
16031603
"parameters": [
16041604
{
16051605
"in": "query",
1606-
"name": "distinct_on",
1606+
"name": "distinctOn",
16071607
"required": false,
16081608
"schema": {
16091609
"type": "array",
@@ -1672,7 +1672,7 @@
16721672
"parameters": [
16731673
{
16741674
"in": "query",
1675-
"name": "distinct_on",
1675+
"name": "distinctOn",
16761676
"required": false,
16771677
"schema": {
16781678
"type": "array",
@@ -1786,9 +1786,7 @@
17861786
"application/json": {
17871787
"schema": {
17881788
"type": "object",
1789-
"required": [
1790-
"where"
1791-
],
1789+
"required": ["where"],
17921790
"properties": {
17931791
"where": {
17941792
"$ref": "#/components/schemas/users_bool_exp"
@@ -1820,9 +1818,7 @@
18201818
"application/json": {
18211819
"schema": {
18221820
"type": "object",
1823-
"required": [
1824-
"objects"
1825-
],
1821+
"required": ["objects"],
18261822
"properties": {
18271823
"objects": {
18281824
"type": "array",
@@ -1860,9 +1856,7 @@
18601856
"application/json": {
18611857
"schema": {
18621858
"type": "object",
1863-
"required": [
1864-
"where"
1865-
],
1859+
"required": ["where"],
18661860
"properties": {
18671861
"_set": {
18681862
"$ref": "#/components/schemas/users_set_input"
@@ -1893,10 +1887,7 @@
18931887
"schemas": {
18941888
"Query": {
18951889
"type": "object",
1896-
"required": [
1897-
"users",
1898-
"users_aggregate"
1899-
],
1890+
"required": ["users", "users_aggregate"],
19001891
"properties": {
19011892
"capsule": {
19021893
"$ref": "#/components/schemas/Capsule"
@@ -3996,6 +3987,27 @@
39963987
}
39973988
}
39983989
},
3990+
"users_select_column": {
3991+
"type": "object",
3992+
"required": [],
3993+
"properties": {
3994+
"id": {
3995+
"type": "object"
3996+
},
3997+
"name": {
3998+
"type": "object"
3999+
},
4000+
"rocket": {
4001+
"type": "object"
4002+
},
4003+
"timestamp": {
4004+
"type": "object"
4005+
},
4006+
"twitter": {
4007+
"type": "object"
4008+
}
4009+
}
4010+
},
39994011
"users_order_by": {
40004012
"type": "object",
40014013
"required": [],
@@ -4190,10 +4202,7 @@
41904202
},
41914203
"users": {
41924204
"type": "object",
4193-
"required": [
4194-
"id",
4195-
"timestamp"
4196-
],
4205+
"required": ["id", "timestamp"],
41974206
"properties": {
41984207
"id": {
41994208
"type": "object"
@@ -4214,9 +4223,7 @@
42144223
},
42154224
"users_aggregate": {
42164225
"type": "object",
4217-
"required": [
4218-
"nodes"
4219-
],
4226+
"required": ["nodes"],
42204227
"properties": {
42214228
"aggregate": {
42224229
"$ref": "#/components/schemas/users_aggregate_fields"
@@ -4298,10 +4305,7 @@
42984305
},
42994306
"users_mutation_response": {
43004307
"type": "object",
4301-
"required": [
4302-
"affected_rows",
4303-
"returning"
4304-
],
4308+
"required": ["affected_rows", "returning"],
43054309
"properties": {
43064310
"affected_rows": {
43074311
"type": "integer",
@@ -4338,10 +4342,7 @@
43384342
},
43394343
"users_on_conflict": {
43404344
"type": "object",
4341-
"required": [
4342-
"constraint",
4343-
"update_columns"
4344-
],
4345+
"required": ["constraint", "update_columns"],
43454346
"properties": {
43464347
"constraint": {
43474348
"type": "object"
@@ -4377,10 +4378,7 @@
43774378
},
43784379
"Subscription": {
43794380
"type": "object",
4380-
"required": [
4381-
"users",
4382-
"users_aggregate"
4383-
],
4381+
"required": ["users", "users_aggregate"],
43844382
"properties": {
43854383
"users": {
43864384
"type": "array",
@@ -4462,9 +4460,7 @@
44624460
},
44634461
"users_arr_rel_insert_input": {
44644462
"type": "object",
4465-
"required": [
4466-
"data"
4467-
],
4463+
"required": ["data"],
44684464
"properties": {
44694465
"data": {
44704466
"type": "array",
@@ -4479,9 +4475,7 @@
44794475
},
44804476
"users_obj_rel_insert_input": {
44814477
"type": "object",
4482-
"required": [
4483-
"data"
4484-
],
4478+
"required": ["data"],
44854479
"properties": {
44864480
"data": {
44874481
"type": "object"
@@ -4493,4 +4487,4 @@
44934487
}
44944488
}
44954489
}
4496-
}
4490+
}

0 commit comments

Comments
 (0)