Skip to content

Commit c02bc37

Browse files
Add YAML versions of default configuration files
Co-authored-by: waldekmastykarz <11164679+waldekmastykarz@users.noreply.github.com>
1 parent eaaa42f commit c02bc37

3 files changed

Lines changed: 105 additions & 0 deletions

File tree

DevProxy/DevProxy.csproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,15 @@
5757
<None Update="devproxyrc.json">
5858
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
5959
</None>
60+
<None Update="devproxyrc.yaml">
61+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
62+
</None>
6063
<None Update="devproxy-errors.json">
6164
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
6265
</None>
66+
<None Update="devproxy-errors.yaml">
67+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
68+
</None>
6369
<None Update="remove-cert.sh">
6470
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
6571
</None>

DevProxy/devproxy-errors.yaml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# yaml-language-server: $schema=https://raw.githubusercontent.com/dotnet/dev-proxy/main/schemas/v2.2.0/genericrandomerrorplugin.errorsfile.schema.json
2+
# Dev Proxy error responses configuration
3+
# This YAML version serves as a reference example alongside the default JSON configuration.
4+
# It demonstrates YAML features like comments, multiline strings, and anchors.
5+
6+
# Define reusable error body templates using YAML anchors
7+
definitions:
8+
client_error_body: &client_error_body
9+
message: "Client Error"
10+
11+
server_error_body: &server_error_body
12+
message: "Server Error"
13+
14+
errors:
15+
- request:
16+
url: "https://*/*"
17+
responses:
18+
- statusCode: 400
19+
body:
20+
<<: *client_error_body
21+
message: Bad Request
22+
details: The server cannot process the request due to invalid syntax.
23+
24+
- statusCode: 401
25+
body:
26+
<<: *client_error_body
27+
message: Unauthorized
28+
details: The request requires user authentication.
29+
30+
- statusCode: 403
31+
body:
32+
<<: *client_error_body
33+
message: Forbidden
34+
details: The server understood the request, but refuses to authorize it.
35+
36+
- statusCode: 404
37+
body:
38+
<<: *client_error_body
39+
message: Not Found
40+
details: The requested resource could not be found.
41+
42+
- statusCode: 418
43+
body:
44+
message: I'm a teapot
45+
details: The server refuses the attempt to brew coffee with a teapot.
46+
47+
- statusCode: 429
48+
body:
49+
message: Too Many Requests
50+
details: >-
51+
The user has sent too many requests in a given amount of time
52+
("rate limiting").
53+
headers:
54+
- name: Retry-After
55+
value: "@dynamic"
56+
57+
- statusCode: 500
58+
body:
59+
<<: *server_error_body
60+
message: Internal Server Error
61+
details: >-
62+
The server encountered an internal error and was unable to complete
63+
your request. Either the server is overloaded or there is an error
64+
in the application.
65+
66+
- statusCode: 503
67+
body:
68+
<<: *server_error_body
69+
message: Service Unavailable
70+
details: >-
71+
The server is currently unable to handle the request due to a
72+
temporary overload or maintenance. Please try again later.

DevProxy/devproxyrc.yaml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# yaml-language-server: $schema=https://raw.githubusercontent.com/dotnet/dev-proxy/main/schemas/v2.2.0/rc.schema.json
2+
# Dev Proxy configuration file
3+
# This YAML version serves as a reference example alongside the default JSON configuration.
4+
5+
plugins:
6+
- name: RetryAfterPlugin
7+
enabled: true
8+
pluginPath: "~appFolder/plugins/DevProxy.Plugins.dll"
9+
10+
- name: GenericRandomErrorPlugin
11+
enabled: true
12+
pluginPath: "~appFolder/plugins/DevProxy.Plugins.dll"
13+
configSection: genericRandomErrorPlugin
14+
15+
urlsToWatch:
16+
- "https://jsonplaceholder.typicode.com/*"
17+
18+
genericRandomErrorPlugin:
19+
# yaml-language-server: $schema=https://raw.githubusercontent.com/dotnet/dev-proxy/main/schemas/v2.2.0/genericrandomerrorplugin.schema.json
20+
errorsFile: devproxy-errors.yaml
21+
rate: 50
22+
23+
logLevel: information
24+
newVersionNotification: stable
25+
showSkipMessages: true
26+
showTimestamps: true
27+
validateSchemas: true

0 commit comments

Comments
 (0)