Skip to content

Commit e4851b2

Browse files
authored
Merge pull request #128 from manifoldco/dangodev/fix-no-types
Fix definitions with missing types
2 parents a774553 + 1e4ebfc commit e4851b2

15 files changed

+539
-112
lines changed

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
example/*.ts

README.md

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -99,14 +99,14 @@ For anything more complicated, or for generating specs dynamically, you can also
9999

100100
#### CLI Options
101101

102-
| Option | Alias | Default | Description |
103-
| :-------------------- | :---- | :--------------------------: | :----------------------------------------------------------------------- |
104-
| `--wrapper` | `-w` | `declare namespace OpenAPI2` | How should this export the types? |
105-
| `--output [location]` | `-o` | (stdout) | Where should the output file be saved? |
106-
| `--swagger [version]` | `-s` | `2` | specify Swagger version (currently only supports `2`) |
107-
| `--camelcase` | `-c` | `false` | convert `snake_case` properties to `camelCase` |
108-
| `--injectWarning` | `-iw` | `false` | injects an “autogenerated file” warning at the top of the generated file |
109-
| `--nowrapper` | `-nw` | `false` | disables rendering a wrapper |
102+
| Option | Alias | Default | Description |
103+
| :-------------------- | :---- | :--------------------------: | :---------------------------------------------------------------------------- |
104+
| `--wrapper` | `-w` | `declare namespace OpenAPI2` | How should this export the types? |
105+
| `--output [location]` | `-o` | (stdout) | Where should the output file be saved? |
106+
| `--swagger [version]` | `-s` | `2` | Manually specify Swagger version (by default it will use `version` in schema) |
107+
| `--camelcase` | `-c` | `false` | Convert `snake_case` properties to `camelCase` |
108+
| `--nowarning` | | `false` | Disables “autogenerated file” warning at the top of generated files |
109+
| `--nowrapper` | `-nw` | `false` | Disables rendering a wrapper |
110110

111111
### Node
112112

@@ -131,18 +131,20 @@ If your specs are in YAML, you’ll have to convert them to JS objects using a l
131131

132132
#### Node Options
133133

134-
| Name | Type | Default | Description |
135-
| :--------------- | :---------------: | :--------------------------: | :-------------------------------------------------------------------------- |
136-
| `wrapper` | `string \| false` | `declare namespace OpenAPI2` | How should this export the types? Pass false to disable rendering a wrapper |
137-
| `swagger` | `number` | `2` | Which Swagger version to use. Currently only supports `2`. |
138-
| `camelcase` | `boolean` | `false` | Convert `snake_case` properties to `camelCase` |
139-
| `propertyMapper` | `function` | `undefined` | Allows you to further manipulate how properties are parsed. See below. |
140-
134+
| Name | Type | Default | Description |
135+
| :--------------- | :---------------: | :--------------------------: | :--------------------------------------------------------------------------- |
136+
| `wrapper` | `string \| false` | `declare namespace OpenAPI2` | How should this export the types? Pass false to disable rendering a wrapper |
137+
| `swagger` | `number` | `2` | Manully specify Swagger version (by default it will use `version` in schema) |
138+
| `camelcase` | `boolean` | `false` | Convert `snake_case` properties to `camelCase` |
139+
| `propertyMapper` | `function` | `undefined` | Allows you to further manipulate how properties are parsed. See below. |
141140

142141
#### PropertyMapper
143-
In order to allow more control over how properties are parsed, and to specifically handle `x-something`-properties, the `propertyMapper` option may be specified.
144142

145-
This is a function that, if specified, is called for each property and allows you to change how swagger-to-ts handles parsing of swagger files.
143+
In order to allow more control over how properties are parsed, and to specifically handle
144+
`x-something`-properties, the `propertyMapper` option may be specified.
145+
146+
This is a function that, if specified, is called for each property and allows you to change how
147+
swagger-to-ts handles parsing of swagger files.
146148

147149
An example on how to use the `x-nullable` property to control if a property is optional:
148150

@@ -163,7 +165,6 @@ An example on how to use the `x-nullable` property to control if a property is o
163165
const output = swaggerToTS(swagger, { propertyMapper });
164166
```
165167

166-
167168
[glob]: https://www.npmjs.com/package/glob
168169
[js-yaml]: https://www.npmjs.com/package/js-yaml
169170
[namespace]: https://www.typescriptlang.org/docs/handbook/namespaces.html

bin/cli.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Options
2020
--camelcase, -c convert snake_case properties to camelCase (default: off)
2121
--swagger, -s specify Swagger version (default: 2)
2222
--nowrapper -nw disables rendering the wrapper
23-
--injectWarning -iw injects a warning at the top of the generated file (default: off)
23+
--no-warning hides the warning at the top of the generated file (default: off)
2424
`,
2525
{
2626
flags: {
@@ -54,9 +54,9 @@ Options
5454
type: 'boolean',
5555
alias: 'nw',
5656
},
57-
injectWarning: {
57+
warning: {
5858
type: 'boolean',
59-
alias: 'iw',
59+
default: true,
6060
},
6161
},
6262
}
File renamed without changes.
File renamed without changes.

example/no-types.ts

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
/**
2+
* This file was auto-generated by swagger-to-ts.
3+
* Do not make direct changes to the file.
4+
*/
5+
6+
declare namespace OpenAPI2 {
7+
export interface SubscriptionDetails {
8+
id?: string;
9+
email?: string;
10+
confirmed?: boolean;
11+
firstName?: string;
12+
lastName?: string;
13+
country?: string;
14+
city?: string;
15+
}
16+
export interface SignedMessage {
17+
message: string;
18+
signature: string;
19+
}
20+
export interface NewAccountReferal {
21+
referrerId: string;
22+
newAccount: string;
23+
}
24+
export interface GoogleWalletItem {
25+
id: GoogleFileIdent;
26+
wallet?: string;
27+
}
28+
export interface GoogleToken {
29+
token: string;
30+
}
31+
export interface GooglePutRequest {
32+
token: GoogleToken;
33+
wallet: string;
34+
walletName: string;
35+
}
36+
export interface GoogleListResult {
37+
wallets: GoogleFileIdent[];
38+
}
39+
export interface GoogleGetResult {
40+
wallets: GoogleWalletItem[];
41+
}
42+
export interface GoogleFileIdent {
43+
id: string;
44+
name?: string;
45+
type?: string;
46+
}
47+
export interface GoogleAuthUrl {
48+
url: string;
49+
}
50+
export interface ETransferPacket {
51+
email: string;
52+
question: string;
53+
answer: string;
54+
message?: string;
55+
}
56+
export interface eTransferCodeResponse {
57+
code?: string;
58+
error?: string;
59+
}
60+
export interface EncryptedPacket {
61+
encryptedPacket: string;
62+
version: string;
63+
}
64+
export interface CertifiedTransferResponse {
65+
message: string;
66+
txHash: string;
67+
}
68+
export interface CertifiedTransferRequest {
69+
from: string;
70+
to: string;
71+
value: number;
72+
fee: number;
73+
timestamp: number;
74+
signature: string;
75+
}
76+
export interface CertifiedTransfer {
77+
transfer: CertifiedTransferRequest;
78+
instructionPacket: EncryptedPacket;
79+
signature: string;
80+
}
81+
export interface BrokerStatus {
82+
address: string;
83+
certifiedFee: number;
84+
}
85+
export interface BillPayeePacket {
86+
payee?: string;
87+
accountNumber?: string;
88+
}
89+
}

0 commit comments

Comments
 (0)