You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/OpenApiClientProvider.md
+17Lines changed: 17 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -21,9 +21,26 @@ let client = PetStore.Client()
21
21
|`IgnoreControllerPrefix`| Do not parse `operationsId` as `<controllerName>_<methodName>` and generate one client class for all operations. Default value `true`. |
22
22
|`PreferNullable`| Provide `Nullable<_>` for not required properties, instead of `Option<_>`. Defaults value `false`. |
23
23
|`PreferAsync`| Generate async actions of type `Async<'T>` instead of `Task<'T>`. Defaults value `false`. |
24
+
|`SsrfProtection`| Enable SSRF protection (blocks HTTP and localhost). Set to `false` for development/testing. Default value `true`. |
24
25
25
26
More configuration scenarios are described in [Customization section](/Customization)
26
27
28
+
## Security (SSRF Protection)
29
+
30
+
By default, SwaggerProvider blocks HTTP URLs and localhost/private IP addresses to prevent [SSRF attacks](https://owasp.org/www-community/attacks/Server_Side_Request_Forgery).
31
+
32
+
For **development and testing** with local servers, disable SSRF protection:
33
+
34
+
```fsharp
35
+
// Development: Allow HTTP and localhost
36
+
type LocalApi = OpenApiClientProvider<"http://localhost:5000/swagger.json", SsrfProtection=false>
37
+
38
+
// Production: HTTPS with SSRF protection (default)
39
+
type ProdApi = OpenApiClientProvider<"https://api.example.com/swagger.json">
40
+
```
41
+
42
+
**Warning:** Never set `SsrfProtection=false` in production code.
43
+
27
44
## Sample
28
45
29
46
Sample uses [TaskBuilder.fs](https://github.com/rspeele/TaskBuilder.fs) (F# computation expression builder for System.Threading.Tasks) that will become part of [Fsharp.Core.dll] one day [[WIP, RFC FS-1072] task support](https://github.com/dotnet/fsharp/pull/6811).
Copy file name to clipboardExpand all lines: docs/SwaggerClientProvider.md
+17Lines changed: 17 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -28,9 +28,26 @@ When you use TP you can specify the following parameters
28
28
|`IgnoreControllerPrefix`| Do not parse `operationsId` as `<controllerName>_<methodName>` and generate one client class for all operations. Default value `true`. |
29
29
|`PreferNullable`| Provide `Nullable<_>` for not required properties, instead of `Option<_>`. Defaults value `false`. |
30
30
|`PreferAsync`| Generate async actions of type `Async<'T>` instead of `Task<'T>`. Defaults value `false`. |
31
+
|`SsrfProtection`| Enable SSRF protection (blocks HTTP and localhost). Set to `false` for development/testing. Default value `true`. |
31
32
32
33
More configuration scenarios are described in [Customization section](/Customization)
33
34
35
+
## Security (SSRF Protection)
36
+
37
+
By default, SwaggerProvider blocks HTTP URLs and localhost/private IP addresses to prevent [SSRF attacks](https://owasp.org/www-community/attacks/Server_Side_Request_Forgery).
38
+
39
+
For **development and testing** with local servers, disable SSRF protection:
40
+
41
+
```fsharp
42
+
// Development: Allow HTTP and localhost
43
+
type LocalApi = SwaggerClientProvider<"http://localhost:5000/swagger.json", SsrfProtection=false>
44
+
45
+
// Production: HTTPS with SSRF protection (default)
46
+
type ProdApi = SwaggerClientProvider<"https://api.example.com/swagger.json">
47
+
```
48
+
49
+
**Warning:** Never set `SsrfProtection=false` in production code.
50
+
34
51
## Sample
35
52
36
53
The usage is very similar to [OpenApiClientProvider](/OpenApiClientProvider#sample)
<param name='Schema'>Url or Path to OpenAPI schema file.</param>
44
45
<param name='IgnoreOperationId'>Do not use `operationsId` and generate method names using `path` only. Default value `false`.</param>
45
46
<param name='IgnoreControllerPrefix'>Do not parse `operationsId` as `<controllerName>_<methodName>` and generate one client class for all operations. Default value `true`.</param>
46
47
<param name='PreferNullable'>Provide `Nullable<_>` for not required properties, instead of `Option<_>`. Defaults value `false`.</param>
47
-
<param name='PreferAsync'>Generate async actions of type `Async<'T>` instead of `Task<'T>`. Defaults value `false`.</param>"""
48
+
<param name='PreferAsync'>Generate async actions of type `Async<'T>` instead of `Task<'T>`. Defaults value `false`.</param>
49
+
<param name='SsrfProtection'>Enable SSRF protection (blocks HTTP and localhost). Set to false for development/testing. Default value `true`.</param>"""
48
50
49
51
t.DefineStaticParameters(
50
52
staticParams,
@@ -57,15 +59,19 @@ type public OpenApiClientTypeProvider(cfg: TypeProviderConfig) as this =
@@ -44,7 +45,8 @@ type public SwaggerTypeProvider(cfg: TypeProviderConfig) as this =
44
45
<param name='IgnoreOperationId'>Do not use `operationsId` and generate method names using `path` only. Default value `false`.</param>
45
46
<param name='IgnoreControllerPrefix'>Do not parse `operationsId` as `<controllerName>_<methodName>` and generate one client class for all operations. Default value `true`.</param>
46
47
<param name='PreferNullable'>Provide `Nullable<_>` for not required properties, instead of `Option<_>`. Defaults value `false`.</param>
47
-
<param name='PreferAsync'>Generate async actions of type `Async<'T>` instead of `Task<'T>`. Defaults value `false`.</param>"""
48
+
<param name='PreferAsync'>Generate async actions of type `Async<'T>` instead of `Task<'T>`. Defaults value `false`.</param>
49
+
<param name='SsrfProtection'>Enable SSRF protection (blocks HTTP and localhost). Set to false for development/testing. Default value `true`.</param>"""
48
50
49
51
t.DefineStaticParameters(
50
52
staticParams,
@@ -58,15 +60,16 @@ type public SwaggerTypeProvider(cfg: TypeProviderConfig) as this =
"Invalid Content-Type for schema: %s. Expected JSON or YAML content types only. This protects against SSRF attacks. Set SsrfProtection=false to disable this validation."
0 commit comments