Skip to content

Commit 3ed2fad

Browse files
authored
Merge pull request #8970 from swagger-api/nodejs_samples
added nodejs sample.
2 parents 000715b + 8127672 commit 3ed2fad

22 files changed

+3756
-2
lines changed

bin/nodejs-petstore-server.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,6 @@ fi
2626

2727
# if you've executed sbt assembly previously it will use that instead.
2828
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -Dlogback.configurationFile=bin/logback.xml"
29-
ags="$@ generate -t modules/swagger-codegen/src/main/resources/nodejs -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l nodejs-server -o samples/server/petstore/nodejs -Dservice"
29+
ags="$@ generate -i modules/swagger-codegen/src/test/resources/3_0_0/petstore-with-fake-endpoints-models-for-testing.yaml -l nodejs-server -o samples/server/petstore/nodejs -Dservice"
3030

31-
# java $JAVA_OPTS -jar $executable $ags
31+
java $JAVA_OPTS -jar $executable $ags

modules/swagger-codegen/src/test/resources/3_0_0/petstore-with-fake-endpoints-models-for-testing.yaml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1052,6 +1052,9 @@ components:
10521052
type: string
10531053
xml:
10541054
name: Category
1055+
example:
1056+
id: 0
1057+
category: "test-category-name"
10551058
User:
10561059
type: object
10571060
properties:
@@ -1077,6 +1080,15 @@ components:
10771080
format: int32
10781081
xml:
10791082
name: User
1083+
example:
1084+
id: 0
1085+
username: "hugomario"
1086+
firstName: "hugo"
1087+
lastName: "mercado"
1088+
1089+
password: "*****"
1090+
phone: "000-00000000"
1091+
userStatus: 1
10801092
OuterNumber:
10811093
type: number
10821094
ArrayOfNumberOnly:
@@ -1086,6 +1098,19 @@ components:
10861098
type: array
10871099
items:
10881100
type: number
1101+
example:
1102+
id: 0
1103+
ArrayNumber:
1104+
- 0
1105+
- 1
1106+
- 2
1107+
- 3
1108+
- 4
1109+
- 5
1110+
- 6
1111+
- 7
1112+
- 8
1113+
- 9
10891114
Capitalization:
10901115
type: object
10911116
properties:
@@ -1103,6 +1128,11 @@ components:
11031128
type: string
11041129
description: |
11051130
Name of the pet
1131+
example:
1132+
smallCamel: "testProperty"
1133+
CapitalCamel: "TestProperty"
1134+
small_Snake: "test_property"
1135+
Capital_Snake: "Test_Property"
11061136
MixedPropertiesAndAdditionalPropertiesClass:
11071137
type: object
11081138
properties:
@@ -1116,6 +1146,9 @@ components:
11161146
type: object
11171147
additionalProperties:
11181148
$ref: '#/components/schemas/Animal'
1149+
example:
1150+
uuid: "bbe4001e-f700-11e8-8eb2-f2801f1b9fd1"
1151+
dateTime: "2018-11-05 09:25"
11191152
ApiResponse:
11201153
type: object
11211154
properties:
@@ -1488,6 +1521,21 @@ components:
14881521
- sold
14891522
xml:
14901523
name: Pet
1524+
example:
1525+
photoUrls:
1526+
- "photoUrls"
1527+
- "photoUrls"
1528+
name: "doggie"
1529+
id: 0
1530+
category:
1531+
name: "name"
1532+
id: 6
1533+
tags:
1534+
- name: "name"
1535+
id: 1
1536+
- name: "name"
1537+
id: 1
1538+
status: "available"
14911539
hasOnlyReadOnly:
14921540
type: object
14931541
properties:
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Swagger Codegen Ignore
2+
# Generated by swagger-codegen https://github.com/swagger-api/swagger-codegen
3+
4+
# Use this file to prevent files from being overwritten by the generator.
5+
# The patterns follow closely to .gitignore or .dockerignore.
6+
7+
# As an example, the C# client generator defines ApiClient.cs.
8+
# You can make changes and tell Swagger Codgen to ignore just this file by uncommenting the following line:
9+
#ApiClient.cs
10+
11+
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
12+
#foo/*/qux
13+
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
14+
15+
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
16+
#foo/**/qux
17+
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
18+
19+
# You can also negate patterns with an exclamation (!).
20+
# For example, you can ignore all files in a docs folder with the file extension .md:
21+
#docs/*.md
22+
# Then explicitly reverse the ignore rule for a single file:
23+
#!docs/README.md
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.0.4-SNAPSHOT
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Swagger generated server
2+
3+
## Overview
4+
This server was generated by the [swagger-codegen](https://github.com/swagger-api/swagger-codegen) project. By using the [OpenAPI-Spec](https://github.com/OAI/OpenAPI-Specification) from a remote server, you can easily generate a server stub.
5+
6+
### Running the server
7+
To run the server, run:
8+
9+
```
10+
npm start
11+
```
12+
13+
To view the Swagger UI interface:
14+
15+
```
16+
open http://localhost:8080/docs
17+
```
18+
19+
This project leverages the mega-awesome [swagger-tools](https://github.com/apigee-127/swagger-tools) middleware which does most all the work.

0 commit comments

Comments
 (0)