Skip to content

Commit 3c723df

Browse files
author
Stefan Wille
committed
operationId
1 parent fdf709e commit 3c723df

File tree

9 files changed

+434
-1
lines changed

9 files changed

+434
-1
lines changed

myapi.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,15 @@ paths:
77
/posts:
88
get:
99
description: Returns all posts
10+
tags: ['Posts']
11+
operationId: "getPosts"
12+
responses:
13+
'200':
14+
description: Successful response
15+
post:
16+
description: Creates a new post
17+
tags: ['Posts']
18+
operationId: "createPost"
1019
responses:
1120
'200':
1221
description: Successful response

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"web-vitals": "^1.0.1"
1919
},
2020
"scripts": {
21-
"codegen": "openapi-generator-cli generate -i ./myapi.yaml -g typescript-fetch -o generated-sources/openapi --additional-properties=supportsES6=true,npmVersion=6.9.0",
21+
"codegen": "rm -rf src/generated-sources/openapi; openapi-generator-cli generate -i ./myapi.yaml -g typescript-fetch -o src/generated-sources/openapi --additional-properties=supportsES6=true,npmVersion=6.9.0",
2222
"start": "react-scripts start",
2323
"build": "react-scripts build",
2424
"test": "react-scripts test",
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# OpenAPI Generator Ignore
2+
# Generated by openapi-generator https://github.com/openapitools/openapi-generator
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 OpenAPI Generator 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: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.openapi-generator-ignore
2+
apis/PostsApi.ts
3+
apis/index.ts
4+
index.ts
5+
runtime.ts
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
5.1.1
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
/* tslint:disable */
2+
/* eslint-disable */
3+
/**
4+
* My API
5+
* An OpenAPI example API
6+
*
7+
* The version of the OpenAPI document: 1.0.0
8+
*
9+
*
10+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
11+
* https://openapi-generator.tech
12+
* Do not edit the class manually.
13+
*/
14+
15+
16+
import * as runtime from '../runtime';
17+
18+
/**
19+
*
20+
*/
21+
export class PostsApi extends runtime.BaseAPI {
22+
23+
/**
24+
* Creates a new post
25+
*/
26+
async createPostRaw(): Promise<runtime.ApiResponse<void>> {
27+
const queryParameters: any = {};
28+
29+
const headerParameters: runtime.HTTPHeaders = {};
30+
31+
const response = await this.request({
32+
path: `/posts`,
33+
method: 'POST',
34+
headers: headerParameters,
35+
query: queryParameters,
36+
});
37+
38+
return new runtime.VoidApiResponse(response);
39+
}
40+
41+
/**
42+
* Creates a new post
43+
*/
44+
async createPost(): Promise<void> {
45+
await this.createPostRaw();
46+
}
47+
48+
/**
49+
* Returns all posts
50+
*/
51+
async getPostsRaw(): Promise<runtime.ApiResponse<void>> {
52+
const queryParameters: any = {};
53+
54+
const headerParameters: runtime.HTTPHeaders = {};
55+
56+
const response = await this.request({
57+
path: `/posts`,
58+
method: 'GET',
59+
headers: headerParameters,
60+
query: queryParameters,
61+
});
62+
63+
return new runtime.VoidApiResponse(response);
64+
}
65+
66+
/**
67+
* Returns all posts
68+
*/
69+
async getPosts(): Promise<void> {
70+
await this.getPostsRaw();
71+
}
72+
73+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './PostsApi';
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export * from './runtime';
2+
export * from './apis';

0 commit comments

Comments
 (0)