openapi-client-codegen 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- openapi_client_codegen/__init__.py +15 -0
- openapi_client_codegen/_data/configs/csharp.json +24 -0
- openapi_client_codegen/_data/configs/python.json +22 -0
- openapi_client_codegen/_data/openapi-generator-ignore +3 -0
- openapi_client_codegen/_data/templates-patches/csharp/0001-csharp-remove-errant-comma.patch +14 -0
- openapi_client_codegen/_data/templates-patches/csharp/0002-csharp-models-required-only-constructors.patch +75 -0
- openapi_client_codegen/_data/templates-patches/csharp/0003-csharp-httpclient-use-defaultT.patch +14 -0
- openapi_client_codegen/_data/templates-patches/csharp/0004-csharp-support-hybrid-multipart-payloads.patch +144 -0
- openapi_client_codegen/_data/templates-patches/csharp/0006-csharp-streaming-download-response.patch +34 -0
- openapi_client_codegen/_data/templates-patches/csharp/0007-csharp-model-default-initializers.patch +13 -0
- openapi_client_codegen/_data/templates-patches/csharp/0008-csharp-redirect-documentation-file.patch +18 -0
- openapi_client_codegen/cli.py +53 -0
- openapi_client_codegen/client.py +115 -0
- openapi_client_codegen/downgrade.py +132 -0
- openapi_client_codegen/naming.py +26 -0
- openapi_client_codegen/py.typed +0 -0
- openapi_client_codegen/resources.py +8 -0
- openapi_client_codegen/templates.py +30 -0
- openapi_client_codegen/unity.py +75 -0
- openapi_client_codegen-0.1.0.dist-info/METADATA +9 -0
- openapi_client_codegen-0.1.0.dist-info/RECORD +25 -0
- openapi_client_codegen-0.1.0.dist-info/WHEEL +4 -0
- openapi_client_codegen-0.1.0.dist-info/entry_points.txt +2 -0
- openapi_client_codegen-0.1.0.dist-info/licenses/LICENSE +201 -0
- openapi_client_codegen-0.1.0.dist-info/licenses/NOTICE +1 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
from .client import generate_client
|
|
2
|
+
from .downgrade import downgrade_openapi_3_1_to_3_0
|
|
3
|
+
from .naming import ClientNaming, DefaultNamingPolicy, NamingPolicy
|
|
4
|
+
from .templates import regenerate_templates
|
|
5
|
+
from .unity import write_unity_package_metadata
|
|
6
|
+
|
|
7
|
+
__all__ = [
|
|
8
|
+
"ClientNaming",
|
|
9
|
+
"DefaultNamingPolicy",
|
|
10
|
+
"NamingPolicy",
|
|
11
|
+
"downgrade_openapi_3_1_to_3_0",
|
|
12
|
+
"generate_client",
|
|
13
|
+
"regenerate_templates",
|
|
14
|
+
"write_unity_package_metadata",
|
|
15
|
+
]
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"generatorName": "csharp",
|
|
3
|
+
"globalProperties": {
|
|
4
|
+
"apiTests": false,
|
|
5
|
+
"modelTests": false,
|
|
6
|
+
"modelDocs": false,
|
|
7
|
+
"apiDocs": false
|
|
8
|
+
},
|
|
9
|
+
"additionalProperties": {
|
|
10
|
+
"library": "httpclient",
|
|
11
|
+
"packageVersion": "0.1.0",
|
|
12
|
+
"targetFramework": "netstandard2.1",
|
|
13
|
+
"validatable": false,
|
|
14
|
+
"conditionalSerialization": true,
|
|
15
|
+
"nullableReferenceTypes": true,
|
|
16
|
+
"sortModelPropertiesByRequiredFlag": true,
|
|
17
|
+
"sortParamsByRequiredFlag": true,
|
|
18
|
+
"caseInsensitiveResponseHeaders": true,
|
|
19
|
+
"examples": false
|
|
20
|
+
},
|
|
21
|
+
"typeMappings": {
|
|
22
|
+
"number": "double"
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"generatorName": "python",
|
|
3
|
+
"globalProperties": {
|
|
4
|
+
"apiTests": false,
|
|
5
|
+
"modelTests": false,
|
|
6
|
+
"modelDocs": false,
|
|
7
|
+
"apiDocs": false
|
|
8
|
+
},
|
|
9
|
+
"additionalProperties": {
|
|
10
|
+
"library": "httpx",
|
|
11
|
+
"packageVersion": "0.1.0",
|
|
12
|
+
"generateSourceCodeOnly": false,
|
|
13
|
+
"hideGenerationTimestamp": true,
|
|
14
|
+
"disallowAdditionalPropertiesIfNotPresent": false,
|
|
15
|
+
"mapNumberTo": "Union[StrictFloat, StrictInt]",
|
|
16
|
+
"useOneOfDiscriminatorLookup": false,
|
|
17
|
+
"examples": false
|
|
18
|
+
},
|
|
19
|
+
"typeMappings": {
|
|
20
|
+
"number": "float"
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# Fix errant comma in generated C# AnyOf classes
|
|
2
|
+
diff --git a/csharp/modelAnyOf.mustache b/csharp/modelAnyOf.mustache
|
|
3
|
+
index f3eac97..036b383 100644
|
|
4
|
+
--- a/csharp/modelAnyOf.mustache
|
|
5
|
+
+++ b/csharp/modelAnyOf.mustache
|
|
6
|
+
@@ -10,7 +10,7 @@
|
|
7
|
+
{{/vendorExtensions.x-com-visible}}
|
|
8
|
+
[JsonConverter(typeof({{classname}}JsonConverter))]
|
|
9
|
+
[DataContract(Name = "{{{name}}}")]
|
|
10
|
+
- {{>visibility}} partial class {{classname}} : AbstractOpenAPISchema, {{#lambda.joinWithComma}}{{#parent}}{{{.}}} {{/parent}}{{#equatable}}IEquatable<{{classname}}> {{/equatable}}{{#validatable}}IValidatableObject {{/validatable}}{{/lambda.joinWithComma}}
|
|
11
|
+
+ {{>visibility}} partial class {{classname}} : {{#lambda.joinWithComma}}AbstractOpenAPISchema {{#parent}}{{{.}}} {{/parent}}{{#equatable}}IEquatable<{{classname}}> {{/equatable}}{{#validatable}}IValidatableObject {{/validatable}}{{/lambda.joinWithComma}}
|
|
12
|
+
{
|
|
13
|
+
{{#isNullable}}
|
|
14
|
+
/// <summary>
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# Generate constructors with only required params, allowing optional params to be set via property setters
|
|
2
|
+
diff --git a/csharp/modelGeneric.mustache b/csharp/modelGeneric.mustache
|
|
3
|
+
index 5a95ada..f0f6ba4 100644
|
|
4
|
+
--- a/csharp/modelGeneric.mustache
|
|
5
|
+
+++ b/csharp/modelGeneric.mustache
|
|
6
|
+
@@ -140,38 +141,20 @@
|
|
7
|
+
{{#hasOnlyReadOnly}}
|
|
8
|
+
[JsonConstructorAttribute]
|
|
9
|
+
{{/hasOnlyReadOnly}}
|
|
10
|
+
- public {{classname}}({{#readWriteVars}}{{{datatypeWithEnum}}}{{#isEnum}}{{^isContainer}}{{^required}}?{{/required}}{{/isContainer}}{{/isEnum}} {{#lambda.camelcase_sanitize_param}}{{name}}{{/lambda.camelcase_sanitize_param}} = {{#defaultValue}}{{^isDateTime}}{{#isString}}{{^isEnum}}@{{/isEnum}}{{/isString}}{{{defaultValue}}}{{/isDateTime}}{{#isDateTime}}default{{/isDateTime}}{{/defaultValue}}{{^defaultValue}}default{{/defaultValue}}{{^-last}}, {{/-last}}{{/readWriteVars}}){{#parent}} : base({{#parentVars}}{{#lambda.camelcase_sanitize_param}}{{name}}{{/lambda.camelcase_sanitize_param}}{{^-last}}, {{/-last}}{{/parentVars}}){{/parent}}
|
|
11
|
+
+ public {{classname}}({{#requiredVars}}{{{datatypeWithEnum}}} {{#lambda.camelcase_sanitize_param}}{{name}}{{/lambda.camelcase_sanitize_param}}{{^-last}}, {{/-last}}{{/requiredVars}}){{#parent}} : base({{#parentVars}}{{#lambda.camelcase_sanitize_param}}{{name}}{{/lambda.camelcase_sanitize_param}}{{^-last}}, {{/-last}}{{/parentVars}}){{/parent}}
|
|
12
|
+
{
|
|
13
|
+
{{#vars}}
|
|
14
|
+
{{^isInherited}}
|
|
15
|
+
{{^isReadOnly}}
|
|
16
|
+
{{#required}}
|
|
17
|
+
- {{^conditionalSerialization}}
|
|
18
|
+
{{^vendorExtensions.x-csharp-value-type}}
|
|
19
|
+
// to ensure "{{#lambda.camelcase_sanitize_param}}{{name}}{{/lambda.camelcase_sanitize_param}}" is required (not null)
|
|
20
|
+
if ({{#lambda.camelcase_sanitize_param}}{{name}}{{/lambda.camelcase_sanitize_param}} == null)
|
|
21
|
+
{
|
|
22
|
+
throw new ArgumentNullException("{{#lambda.camelcase_sanitize_param}}{{name}}{{/lambda.camelcase_sanitize_param}} is a required property for {{classname}} and cannot be null");
|
|
23
|
+
}
|
|
24
|
+
- this.{{name}} = {{#lambda.camelcase_sanitize_param}}{{name}}{{/lambda.camelcase_sanitize_param}};
|
|
25
|
+
{{/vendorExtensions.x-csharp-value-type}}
|
|
26
|
+
- {{#vendorExtensions.x-csharp-value-type}}
|
|
27
|
+
this.{{name}} = {{#lambda.camelcase_sanitize_param}}{{name}}{{/lambda.camelcase_sanitize_param}};
|
|
28
|
+
- {{/vendorExtensions.x-csharp-value-type}}
|
|
29
|
+
- {{/conditionalSerialization}}
|
|
30
|
+
- {{#conditionalSerialization}}
|
|
31
|
+
- {{^vendorExtensions.x-csharp-value-type}}
|
|
32
|
+
- // to ensure "{{#lambda.camelcase_sanitize_param}}{{name}}{{/lambda.camelcase_sanitize_param}}" is required (not null)
|
|
33
|
+
- if ({{#lambda.camelcase_sanitize_param}}{{name}}{{/lambda.camelcase_sanitize_param}} == null)
|
|
34
|
+
- {
|
|
35
|
+
- throw new ArgumentNullException("{{#lambda.camelcase_sanitize_param}}{{name}}{{/lambda.camelcase_sanitize_param}} is a required property for {{classname}} and cannot be null");
|
|
36
|
+
- }
|
|
37
|
+
- this._{{name}} = {{#lambda.camelcase_sanitize_param}}{{name}}{{/lambda.camelcase_sanitize_param}};
|
|
38
|
+
- {{/vendorExtensions.x-csharp-value-type}}
|
|
39
|
+
- {{#vendorExtensions.x-csharp-value-type}}
|
|
40
|
+
- this._{{name}} = {{#lambda.camelcase_sanitize_param}}{{name}}{{/lambda.camelcase_sanitize_param}};
|
|
41
|
+
- {{/vendorExtensions.x-csharp-value-type}}
|
|
42
|
+
- {{/conditionalSerialization}}
|
|
43
|
+
{{/required}}
|
|
44
|
+
{{/isReadOnly}}
|
|
45
|
+
{{/isInherited}}
|
|
46
|
+
@@ -180,29 +163,6 @@
|
|
47
|
+
{{^isInherited}}
|
|
48
|
+
{{^isReadOnly}}
|
|
49
|
+
{{^required}}
|
|
50
|
+
- {{#defaultValue}}
|
|
51
|
+
- {{^conditionalSerialization}}
|
|
52
|
+
- {{^vendorExtensions.x-csharp-value-type}}
|
|
53
|
+
- // use default value if no "{{#lambda.camelcase_sanitize_param}}{{name}}{{/lambda.camelcase_sanitize_param}}" provided
|
|
54
|
+
- this.{{name}} = {{#lambda.camelcase_sanitize_param}}{{name}}{{/lambda.camelcase_sanitize_param}} ?? {{#isString}}@{{/isString}}{{{defaultValue}}};
|
|
55
|
+
- {{/vendorExtensions.x-csharp-value-type}}
|
|
56
|
+
- {{#vendorExtensions.x-csharp-value-type}}
|
|
57
|
+
- this.{{name}} = {{#lambda.camelcase_sanitize_param}}{{name}}{{/lambda.camelcase_sanitize_param}};
|
|
58
|
+
- {{/vendorExtensions.x-csharp-value-type}}
|
|
59
|
+
- {{/conditionalSerialization}}
|
|
60
|
+
- {{/defaultValue}}
|
|
61
|
+
- {{^defaultValue}}
|
|
62
|
+
- {{^conditionalSerialization}}
|
|
63
|
+
- this.{{name}} = {{#lambda.camelcase_sanitize_param}}{{name}}{{/lambda.camelcase_sanitize_param}};
|
|
64
|
+
- {{/conditionalSerialization}}
|
|
65
|
+
- {{#conditionalSerialization}}
|
|
66
|
+
- this._{{name}} = {{#lambda.camelcase_sanitize_param}}{{name}}{{/lambda.camelcase_sanitize_param}};
|
|
67
|
+
- if (this.{{name}} != null)
|
|
68
|
+
- {
|
|
69
|
+
- this._flag{{name}} = true;
|
|
70
|
+
- }
|
|
71
|
+
- {{/conditionalSerialization}}
|
|
72
|
+
- {{/defaultValue}}
|
|
73
|
+
{{/required}}
|
|
74
|
+
{{/isReadOnly}}
|
|
75
|
+
{{/isInherited}}
|
openapi_client_codegen/_data/templates-patches/csharp/0003-csharp-httpclient-use-defaultT.patch
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# Fix issue with target-typed `default` in generic error paths by using `default(T)` for broader C# language version compatibility.
|
|
2
|
+
diff --git a/csharp/libraries/httpclient/ApiClient.mustache b/csharp/libraries/httpclient/ApiClient.mustache
|
|
3
|
+
index fb521d0..9db72d9 100644
|
|
4
|
+
--- a/csharp/libraries/httpclient/ApiClient.mustache
|
|
5
|
+
+++ b/csharp/libraries/httpclient/ApiClient.mustache
|
|
6
|
+
@@ -555,7 +555,7 @@ namespace {{packageName}}.Client
|
|
7
|
+
|
|
8
|
+
if (!response.IsSuccessStatusCode)
|
|
9
|
+
{
|
|
10
|
+
- return await ToApiResponse<T>(response, default, req.RequestUri).ConfigureAwait(false);
|
|
11
|
+
+ return await ToApiResponse<T>(response, default(T), req.RequestUri).ConfigureAwait(false);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
object responseData = await deserializer.Deserialize<T>(response).ConfigureAwait(false);
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
# Serialize complex objects as JSON parts in multipart/form-data requests, enabling hybrid payloads alongside binary files
|
|
2
|
+
diff --git a/csharp/libraries/httpclient/ApiClient.mustache b/csharp/libraries/httpclient/ApiClient.mustache
|
|
3
|
+
index 9db72d9..179dcda 100644
|
|
4
|
+
--- a/csharp/libraries/httpclient/ApiClient.mustache
|
|
5
|
+
+++ b/csharp/libraries/httpclient/ApiClient.mustache
|
|
6
|
+
@@ -312,7 +312,17 @@ namespace {{packageName}}.Client
|
|
7
|
+
{
|
|
8
|
+
var content = new StreamContent(file.Content);
|
|
9
|
+
content.Headers.ContentType = new MediaTypeHeaderValue(file.ContentType);
|
|
10
|
+
- multipartContent.Add(content, fileParam.Key, file.Name);
|
|
11
|
+
+
|
|
12
|
+
+ if (string.IsNullOrEmpty(file.Name))
|
|
13
|
+
+ {
|
|
14
|
+
+ // Add as a normal form part (but with our custom Content-Type)
|
|
15
|
+
+ multipartContent.Add(content, fileParam.Key);
|
|
16
|
+
+ }
|
|
17
|
+
+ else
|
|
18
|
+
+ {
|
|
19
|
+
+ // Add as a file upload (with filename)
|
|
20
|
+
+ multipartContent.Add(content, fileParam.Key, file.Name);
|
|
21
|
+
+ }
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
diff --git a/csharp/libraries/httpclient/api.mustache b/csharp/libraries/httpclient/api.mustache
|
|
26
|
+
index f7330c2..de9cc90 100644
|
|
27
|
+
--- a/csharp/libraries/httpclient/api.mustache
|
|
28
|
+
+++ b/csharp/libraries/httpclient/api.mustache
|
|
29
|
+
@@ -445,7 +445,27 @@ namespace {{packageName}}.{{apiPackage}}
|
|
30
|
+
localVarRequestOptions.FileParameters.Add("{{baseName}}", {{paramName}});
|
|
31
|
+
{{/isFile}}
|
|
32
|
+
{{^isFile}}
|
|
33
|
+
- localVarRequestOptions.FormParameters.Add("{{baseName}}", {{packageName}}.Client.ClientUtils.ParameterToString({{paramName}})); // form parameter
|
|
34
|
+
+ {{#isPrimitiveType}}
|
|
35
|
+
+ // Primitive types (int, string, bool) go as standard form fields
|
|
36
|
+
+ localVarRequestOptions.FormParameters.Add("{{baseName}}", {{packageName}}.Client.ClientUtils.ParameterToString({{paramName}}));
|
|
37
|
+
+ {{/isPrimitiveType}}
|
|
38
|
+
+ {{^isPrimitiveType}}
|
|
39
|
+
+ {{#isEnum}}
|
|
40
|
+
+ // Enums are treated as strings
|
|
41
|
+
+ localVarRequestOptions.FormParameters.Add("{{baseName}}", {{packageName}}.Client.ClientUtils.ParameterToString({{paramName}}));
|
|
42
|
+
+ {{/isEnum}}
|
|
43
|
+
+ {{^isEnum}}
|
|
44
|
+
+ // COMPLEX TYPE: Serialize to JSON and add as a "File" with application/json header
|
|
45
|
+
+ if ({{paramName}} != null)
|
|
46
|
+
+ {
|
|
47
|
+
+ var _json_{{paramName}} = Newtonsoft.Json.JsonConvert.SerializeObject({{paramName}}, this.ApiClient.SerializerSettings);
|
|
48
|
+
+ var _stream_{{paramName}} = new System.IO.MemoryStream(System.Text.Encoding.UTF8.GetBytes(_json_{{paramName}}));
|
|
49
|
+
+
|
|
50
|
+
+ // Add as a file parameter with null filename and application/json content type
|
|
51
|
+
+ localVarRequestOptions.FileParameters.Add("{{baseName}}", new {{packageName}}.Client.FileParameter(null, "application/json", _stream_{{paramName}}));
|
|
52
|
+
+ }
|
|
53
|
+
+ {{/isEnum}}
|
|
54
|
+
+ {{/isPrimitiveType}}
|
|
55
|
+
{{/isFile}}
|
|
56
|
+
{{/required}}
|
|
57
|
+
{{^required}}
|
|
58
|
+
@@ -455,7 +475,27 @@ namespace {{packageName}}.{{apiPackage}}
|
|
59
|
+
localVarRequestOptions.FileParameters.Add("{{baseName}}", {{paramName}});
|
|
60
|
+
{{/isFile}}
|
|
61
|
+
{{^isFile}}
|
|
62
|
+
- localVarRequestOptions.FormParameters.Add("{{baseName}}", {{packageName}}.Client.ClientUtils.ParameterToString({{paramName}})); // form parameter
|
|
63
|
+
+ {{#isPrimitiveType}}
|
|
64
|
+
+ // Primitive types (int, string, bool) go as standard form fields
|
|
65
|
+
+ localVarRequestOptions.FormParameters.Add("{{baseName}}", {{packageName}}.Client.ClientUtils.ParameterToString({{paramName}}));
|
|
66
|
+
+ {{/isPrimitiveType}}
|
|
67
|
+
+ {{^isPrimitiveType}}
|
|
68
|
+
+ {{#isEnum}}
|
|
69
|
+
+ // Enums are treated as strings
|
|
70
|
+
+ localVarRequestOptions.FormParameters.Add("{{baseName}}", {{packageName}}.Client.ClientUtils.ParameterToString({{paramName}}));
|
|
71
|
+
+ {{/isEnum}}
|
|
72
|
+
+ {{^isEnum}}
|
|
73
|
+
+ // COMPLEX TYPE: Serialize to JSON and add as a "File" with application/json header
|
|
74
|
+
+ if ({{paramName}} != null)
|
|
75
|
+
+ {
|
|
76
|
+
+ var _json_{{paramName}} = Newtonsoft.Json.JsonConvert.SerializeObject({{paramName}}, this.ApiClient.SerializerSettings);
|
|
77
|
+
+ var _stream_{{paramName}} = new System.IO.MemoryStream(System.Text.Encoding.UTF8.GetBytes(_json_{{paramName}}));
|
|
78
|
+
+
|
|
79
|
+
+ // Add as a file parameter with null filename and application/json content type
|
|
80
|
+
+ localVarRequestOptions.FileParameters.Add("{{baseName}}", new {{packageName}}.Client.FileParameter(null, "application/json", _stream_{{paramName}}));
|
|
81
|
+
+ }
|
|
82
|
+
+ {{/isEnum}}
|
|
83
|
+
+ {{/isPrimitiveType}}
|
|
84
|
+
{{/isFile}}
|
|
85
|
+
}
|
|
86
|
+
{{/required}}
|
|
87
|
+
@@ -662,7 +702,27 @@ namespace {{packageName}}.{{apiPackage}}
|
|
88
|
+
localVarRequestOptions.FileParameters.Add("{{baseName}}", {{paramName}});
|
|
89
|
+
{{/isFile}}
|
|
90
|
+
{{^isFile}}
|
|
91
|
+
- localVarRequestOptions.FormParameters.Add("{{baseName}}", {{packageName}}.Client.ClientUtils.ParameterToString({{paramName}})); // form parameter
|
|
92
|
+
+ {{#isPrimitiveType}}
|
|
93
|
+
+ // Primitive types (int, string, bool) go as standard form fields
|
|
94
|
+
+ localVarRequestOptions.FormParameters.Add("{{baseName}}", {{packageName}}.Client.ClientUtils.ParameterToString({{paramName}}));
|
|
95
|
+
+ {{/isPrimitiveType}}
|
|
96
|
+
+ {{^isPrimitiveType}}
|
|
97
|
+
+ {{#isEnum}}
|
|
98
|
+
+ // Enums are treated as strings
|
|
99
|
+
+ localVarRequestOptions.FormParameters.Add("{{baseName}}", {{packageName}}.Client.ClientUtils.ParameterToString({{paramName}}));
|
|
100
|
+
+ {{/isEnum}}
|
|
101
|
+
+ {{^isEnum}}
|
|
102
|
+
+ // COMPLEX TYPE: Serialize to JSON and add as a "File" with application/json header
|
|
103
|
+
+ if ({{paramName}} != null)
|
|
104
|
+
+ {
|
|
105
|
+
+ var _json_{{paramName}} = Newtonsoft.Json.JsonConvert.SerializeObject({{paramName}}, this.ApiClient.SerializerSettings);
|
|
106
|
+
+ var _stream_{{paramName}} = new System.IO.MemoryStream(System.Text.Encoding.UTF8.GetBytes(_json_{{paramName}}));
|
|
107
|
+
+
|
|
108
|
+
+ // Add as a file parameter with null filename and application/json content type
|
|
109
|
+
+ localVarRequestOptions.FileParameters.Add("{{baseName}}", new {{packageName}}.Client.FileParameter(null, "application/json", _stream_{{paramName}}));
|
|
110
|
+
+ }
|
|
111
|
+
+ {{/isEnum}}
|
|
112
|
+
+ {{/isPrimitiveType}}
|
|
113
|
+
{{/isFile}}
|
|
114
|
+
{{/required}}
|
|
115
|
+
{{^required}}
|
|
116
|
+
@@ -672,7 +732,27 @@ namespace {{packageName}}.{{apiPackage}}
|
|
117
|
+
localVarRequestOptions.FileParameters.Add("{{baseName}}", {{paramName}});
|
|
118
|
+
{{/isFile}}
|
|
119
|
+
{{^isFile}}
|
|
120
|
+
- localVarRequestOptions.FormParameters.Add("{{baseName}}", {{packageName}}.Client.ClientUtils.ParameterToString({{paramName}})); // form parameter
|
|
121
|
+
+ {{#isPrimitiveType}}
|
|
122
|
+
+ // Primitive types (int, string, bool) go as standard form fields
|
|
123
|
+
+ localVarRequestOptions.FormParameters.Add("{{baseName}}", {{packageName}}.Client.ClientUtils.ParameterToString({{paramName}}));
|
|
124
|
+
+ {{/isPrimitiveType}}
|
|
125
|
+
+ {{^isPrimitiveType}}
|
|
126
|
+
+ {{#isEnum}}
|
|
127
|
+
+ // Enums are treated as strings
|
|
128
|
+
+ localVarRequestOptions.FormParameters.Add("{{baseName}}", {{packageName}}.Client.ClientUtils.ParameterToString({{paramName}}));
|
|
129
|
+
+ {{/isEnum}}
|
|
130
|
+
+ {{^isEnum}}
|
|
131
|
+
+ // COMPLEX TYPE: Serialize to JSON and add as a "File" with application/json header
|
|
132
|
+
+ if ({{paramName}} != null)
|
|
133
|
+
+ {
|
|
134
|
+
+ var _json_{{paramName}} = Newtonsoft.Json.JsonConvert.SerializeObject({{paramName}}, this.ApiClient.SerializerSettings);
|
|
135
|
+
+ var _stream_{{paramName}} = new System.IO.MemoryStream(System.Text.Encoding.UTF8.GetBytes(_json_{{paramName}}));
|
|
136
|
+
+
|
|
137
|
+
+ // Add as a file parameter with null filename and application/json content type
|
|
138
|
+
+ localVarRequestOptions.FileParameters.Add("{{baseName}}", new {{packageName}}.Client.FileParameter(null, "application/json", _stream_{{paramName}}));
|
|
139
|
+
+ }
|
|
140
|
+
+ {{/isEnum}}
|
|
141
|
+
+ {{/isPrimitiveType}}
|
|
142
|
+
{{/isFile}}
|
|
143
|
+
}
|
|
144
|
+
{{/required}}
|
openapi_client_codegen/_data/templates-patches/csharp/0006-csharp-streaming-download-response.patch
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# Stream HTTP response bodies through the generated client: switch SendAsync to ResponseHeadersRead so the body isn't pre-buffered, and skip the rawContent ReadAsStringAsync in ToApiResponse for Stream/FileParameter results whose body has already been consumed by Deserialize via ReadAsStreamAsync.
|
|
2
|
+
diff --git a/csharp/libraries/httpclient/ApiClient.mustache b/csharp/libraries/httpclient/ApiClient.mustache
|
|
3
|
+
index 7177eb4b..e4e0bded 100644
|
|
4
|
+
--- a/csharp/libraries/httpclient/ApiClient.mustache
|
|
5
|
+
+++ b/csharp/libraries/httpclient/ApiClient.mustache
|
|
6
|
+
@@ -445,7 +445,9 @@ namespace {{packageName}}.Client
|
|
7
|
+
private async Task<ApiResponse<T>> ToApiResponse<T>(HttpResponseMessage response, object responseData, Uri uri)
|
|
8
|
+
{
|
|
9
|
+
T result = (T)responseData;
|
|
10
|
+
- string rawContent = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
|
|
11
|
+
+ string rawContent = typeof(T) == typeof(Stream) || typeof(T) == typeof(FileParameter)
|
|
12
|
+
+ ? null
|
|
13
|
+
+ : await response.Content.ReadAsStringAsync().ConfigureAwait(false);
|
|
14
|
+
|
|
15
|
+
var transformed = new ApiResponse<T>(response.StatusCode, new Multimap<string, string>({{#caseInsensitiveResponseHeaders}}StringComparer.OrdinalIgnoreCase{{/caseInsensitiveResponseHeaders}}), result, rawContent)
|
|
16
|
+
{
|
|
17
|
+
@@ -546,7 +548,7 @@ namespace {{packageName}}.Client
|
|
18
|
+
{
|
|
19
|
+
var policy = RetryConfiguration.AsyncRetryPolicy;
|
|
20
|
+
var policyResult = await policy
|
|
21
|
+
- .ExecuteAndCaptureAsync(() => _httpClient.SendAsync(req, finalToken))
|
|
22
|
+
+ .ExecuteAndCaptureAsync(() => _httpClient.SendAsync(req, HttpCompletionOption.ResponseHeadersRead, finalToken))
|
|
23
|
+
.ConfigureAwait(false);
|
|
24
|
+
response = (policyResult.Outcome == OutcomeType.Successful) ?
|
|
25
|
+
policyResult.Result : new HttpResponseMessage()
|
|
26
|
+
@@ -558,7 +560,7 @@ namespace {{packageName}}.Client
|
|
27
|
+
else
|
|
28
|
+
{
|
|
29
|
+
{{/supportsRetry}}
|
|
30
|
+
- response = await _httpClient.SendAsync(req, finalToken).ConfigureAwait(false);
|
|
31
|
+
+ response = await _httpClient.SendAsync(req, HttpCompletionOption.ResponseHeadersRead, finalToken).ConfigureAwait(false);
|
|
32
|
+
{{#supportsRetry}}
|
|
33
|
+
}
|
|
34
|
+
{{/supportsRetry}}
|
openapi_client_codegen/_data/templates-patches/csharp/0007-csharp-model-default-initializers.patch
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Initialize each non-required, non-enum backing field to the OpenAPI default value when one is declared, so `new T()` carries the schema-declared defaults instead of `default(T)`. No cast needed: `float` fields are tagged `format: double` in the spec via `common.litestar.FloatFormatPlugin`, so `toDefaultValue` emits a `D`-suffixed literal that C# accepts as `double` directly; `int` and `bool` defaults are already type-correct.
|
|
2
|
+
diff --git a/csharp/modelGeneric.mustache b/csharp/modelGeneric.mustache
|
|
3
|
+
--- a/csharp/modelGeneric.mustache
|
|
4
|
+
+++ b/csharp/modelGeneric.mustache
|
|
5
|
+
@@ -243,7 +243,7 @@
|
|
6
|
+
_flag{{name}} = true;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
- private {{{dataType}}} _{{name}};
|
|
10
|
+
+ private {{{dataType}}} _{{name}}{{#defaultValue}} = {{{defaultValue}}}{{/defaultValue}};
|
|
11
|
+
private bool _flag{{name}};
|
|
12
|
+
|
|
13
|
+
/// <summary>
|
openapi_client_codegen/_data/templates-patches/csharp/0008-csharp-redirect-documentation-file.patch
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# The csproj ships inside the UPM package as the nuget pack input, and Directory.Build.props
|
|
2
|
+
# (written by unity.write_unity_package_metadata) relocates MSBuild's BaseOutputPath outside the
|
|
3
|
+
# package root. Point DocumentationFile at that relocated base so the docs XML — the one stock
|
|
4
|
+
# template output with a hardwired package-local bin\ path — stops recreating bin/ inside the
|
|
5
|
+
# package on every build. $(BaseOutputPath) is defined by Directory.Build.props, which MSBuild
|
|
6
|
+
# imports before the project body, so it is visible at this property's evaluation point.
|
|
7
|
+
diff --git a/csharp/netcore_project.mustache b/csharp/netcore_project.mustache
|
|
8
|
+
--- a/csharp/netcore_project.mustache
|
|
9
|
+
+++ b/csharp/netcore_project.mustache
|
|
10
|
+
@@ -14,7 +14,7 @@
|
|
11
|
+
<Copyright>{{packageCopyright}}</Copyright>
|
|
12
|
+
<RootNamespace>{{packageName}}</RootNamespace>
|
|
13
|
+
<Version>{{packageVersion}}</Version>
|
|
14
|
+
- <DocumentationFile>bin\$(Configuration)\$(TargetFramework)\{{packageName}}.xml</DocumentationFile>{{#licenseId}}
|
|
15
|
+
+ <DocumentationFile>$(BaseOutputPath)$(Configuration)\$(TargetFramework)\{{packageName}}.xml</DocumentationFile>{{#licenseId}}
|
|
16
|
+
<PackageLicenseExpression>{{.}}</PackageLicenseExpression>{{/licenseId}}
|
|
17
|
+
<RepositoryUrl>https://{{{gitHost}}}/{{{gitUserId}}}/{{{gitRepoId}}}.git</RepositoryUrl>
|
|
18
|
+
<RepositoryType>git</RepositoryType>{{#releaseNote}}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import json
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
from tempfile import TemporaryDirectory
|
|
4
|
+
from typing import Annotated
|
|
5
|
+
|
|
6
|
+
from typer import Argument, Option, Typer
|
|
7
|
+
|
|
8
|
+
from .client import generate_client
|
|
9
|
+
from .downgrade import downgrade_openapi_3_1_to_3_0
|
|
10
|
+
from .naming import DefaultNamingPolicy
|
|
11
|
+
from .templates import regenerate_templates
|
|
12
|
+
|
|
13
|
+
app = Typer(pretty_exceptions_show_locals=False)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
@app.command()
|
|
17
|
+
def downgrade(
|
|
18
|
+
input_file: Annotated[Path, Argument(help="OpenAPI 3.1 JSON to downgrade to 3.0.3")],
|
|
19
|
+
output_file: Annotated[Path | None, Argument(help="Write here instead of overwriting input_file")] = None,
|
|
20
|
+
) -> None:
|
|
21
|
+
schema = json.loads(input_file.read_text(encoding="utf-8"))
|
|
22
|
+
downgrade_openapi_3_1_to_3_0(schema)
|
|
23
|
+
destination = output_file if output_file is not None else input_file
|
|
24
|
+
destination.write_text(json.dumps(schema, indent=2), encoding="utf-8")
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
@app.command()
|
|
28
|
+
def generate(
|
|
29
|
+
spec_file: Annotated[Path, Argument(help="OpenAPI 3.0 spec JSON to generate from")],
|
|
30
|
+
output_dir: Annotated[Path, Argument(help="Directory to sync the generated client into")],
|
|
31
|
+
root_name: Annotated[str, Option(help="Root name handed to DefaultNamingPolicy")],
|
|
32
|
+
project: Annotated[str, Option(help="Project path; its last segment names the client")],
|
|
33
|
+
generator: Annotated[str, Option(help="openapi-generator generator name")] = "csharp",
|
|
34
|
+
npm_scope: Annotated[str | None, Option(help="npm scope composing the UPM package identity")] = None,
|
|
35
|
+
license_spdx: Annotated[str | None, Option(help="SPDX license id written to package.json")] = None,
|
|
36
|
+
repository_url: Annotated[str | None, Option(help="git repository URL written to package.json")] = None,
|
|
37
|
+
) -> None:
|
|
38
|
+
with TemporaryDirectory() as templates_directory_string:
|
|
39
|
+
templates_directory = Path(templates_directory_string)
|
|
40
|
+
templates_dir = templates_directory if generator == "csharp" else None
|
|
41
|
+
if templates_dir is not None:
|
|
42
|
+
regenerate_templates(templates_dir)
|
|
43
|
+
|
|
44
|
+
generate_client(
|
|
45
|
+
spec_file.read_text(encoding="utf-8"),
|
|
46
|
+
generator,
|
|
47
|
+
output_dir,
|
|
48
|
+
DefaultNamingPolicy(root_name)(project),
|
|
49
|
+
templates_dir=templates_dir,
|
|
50
|
+
npm_scope=npm_scope,
|
|
51
|
+
license_spdx=license_spdx,
|
|
52
|
+
repository_url=repository_url,
|
|
53
|
+
)
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import json
|
|
2
|
+
from os import walk
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
from shutil import copytree
|
|
5
|
+
from tempfile import NamedTemporaryFile, TemporaryDirectory
|
|
6
|
+
|
|
7
|
+
from bashrun import bash
|
|
8
|
+
|
|
9
|
+
from .resources import CONFIGS_DIR, IGNORE_FILE, OPENAPI_GENERATOR_CLI_VERSION
|
|
10
|
+
from .naming import ClientNaming
|
|
11
|
+
from .unity import write_unity_package_metadata
|
|
12
|
+
|
|
13
|
+
_HTTP_METHODS = ("get", "put", "post", "delete", "patch", "options", "head", "trace")
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def generate_client(
|
|
17
|
+
spec: str,
|
|
18
|
+
generator: str,
|
|
19
|
+
output_dir: Path,
|
|
20
|
+
names: ClientNaming,
|
|
21
|
+
templates_dir: Path | None = None,
|
|
22
|
+
extra_references: list[str] | None = None,
|
|
23
|
+
npm_scope: str | None = None,
|
|
24
|
+
license_spdx: str | None = None,
|
|
25
|
+
repository_url: str | None = None,
|
|
26
|
+
) -> None:
|
|
27
|
+
if generator == "csharp" and templates_dir is None:
|
|
28
|
+
msg = "csharp client generation requires templates_dir (call regenerate_templates first)"
|
|
29
|
+
raise ValueError(msg)
|
|
30
|
+
|
|
31
|
+
client_config = json.loads((CONFIGS_DIR / f"{generator}.json").read_text(encoding="utf-8"))
|
|
32
|
+
|
|
33
|
+
if generator == "csharp":
|
|
34
|
+
client_config["additionalProperties"]["packageName"] = names.camel
|
|
35
|
+
else:
|
|
36
|
+
client_config["additionalProperties"]["projectName"] = names.dashed
|
|
37
|
+
client_config["additionalProperties"]["packageName"] = names.underscored
|
|
38
|
+
|
|
39
|
+
with (
|
|
40
|
+
NamedTemporaryFile("w+", encoding="utf-8", suffix=".json", delete=False) as temporary_spec_file,
|
|
41
|
+
NamedTemporaryFile("w+", encoding="utf-8", suffix=".json", delete=False) as temporary_config_file,
|
|
42
|
+
TemporaryDirectory() as temporary_directory_string,
|
|
43
|
+
):
|
|
44
|
+
temporary_directory = Path(temporary_directory_string)
|
|
45
|
+
|
|
46
|
+
# Force every operation onto a single "Default" tag so the generator emits one API class
|
|
47
|
+
spec_json = json.loads(spec)
|
|
48
|
+
for path_item in spec_json.get("paths", {}).values():
|
|
49
|
+
for method in _HTTP_METHODS:
|
|
50
|
+
operation = path_item.get(method)
|
|
51
|
+
if isinstance(operation, dict):
|
|
52
|
+
operation["tags"] = ["Default"]
|
|
53
|
+
|
|
54
|
+
json.dump(spec_json, temporary_spec_file)
|
|
55
|
+
temporary_spec_file.flush()
|
|
56
|
+
|
|
57
|
+
json.dump(client_config, temporary_config_file)
|
|
58
|
+
temporary_config_file.flush()
|
|
59
|
+
|
|
60
|
+
command = (
|
|
61
|
+
f"uvx --from 'openapi-generator-cli[jdk4py]=={OPENAPI_GENERATOR_CLI_VERSION}' openapi-generator-cli generate "
|
|
62
|
+
f"-g {generator} "
|
|
63
|
+
f"-i {Path(temporary_spec_file.name).resolve().as_posix()} "
|
|
64
|
+
f"-o {temporary_directory.resolve().as_posix()} "
|
|
65
|
+
f"-c {Path(temporary_config_file.name).resolve().as_posix()} "
|
|
66
|
+
f"--ignore-file-override {IGNORE_FILE.resolve().as_posix()} "
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
if generator == "csharp" and templates_dir is not None:
|
|
70
|
+
command += f" -t {(templates_dir / 'csharp').resolve().as_posix()}"
|
|
71
|
+
|
|
72
|
+
bash(command, env={"JAVA_OPTS": "-Dlog.level=warn"})
|
|
73
|
+
|
|
74
|
+
print(f"Generated {generator} client (temp) at {temporary_directory}")
|
|
75
|
+
|
|
76
|
+
if generator == "csharp":
|
|
77
|
+
npm_name = None if npm_scope is None else f"{npm_scope}.{names.base.replace('-', '')}"
|
|
78
|
+
write_unity_package_metadata(
|
|
79
|
+
temporary_directory / "src" / names.camel,
|
|
80
|
+
names.camel,
|
|
81
|
+
extra_references,
|
|
82
|
+
npm_name=npm_name,
|
|
83
|
+
license_spdx=license_spdx,
|
|
84
|
+
repository_url=repository_url,
|
|
85
|
+
)
|
|
86
|
+
|
|
87
|
+
print(f"Syncing to {output_dir}...")
|
|
88
|
+
|
|
89
|
+
output_dir.mkdir(parents=True, exist_ok=True)
|
|
90
|
+
|
|
91
|
+
# Delete files that no longer exist in the freshly-generated tree
|
|
92
|
+
for target_file in output_dir.rglob("*"):
|
|
93
|
+
if not target_file.is_file():
|
|
94
|
+
continue
|
|
95
|
+
|
|
96
|
+
relative_path = target_file.relative_to(output_dir)
|
|
97
|
+
|
|
98
|
+
# A Unity .meta file shadows a real file; map it back to decide staleness
|
|
99
|
+
if target_file.name.endswith(".meta"):
|
|
100
|
+
relative_path = relative_path.with_name(target_file.name[:-5])
|
|
101
|
+
|
|
102
|
+
if not (temporary_directory / relative_path).exists():
|
|
103
|
+
target_file.unlink()
|
|
104
|
+
|
|
105
|
+
# Delete directories that no longer exist in the freshly-generated tree
|
|
106
|
+
for root, directories, _ in walk(output_dir, topdown=False):
|
|
107
|
+
for name in directories:
|
|
108
|
+
target_directory = Path(root) / name
|
|
109
|
+
if not (temporary_directory / target_directory.relative_to(output_dir)).exists():
|
|
110
|
+
target_directory.rmdir()
|
|
111
|
+
|
|
112
|
+
copytree(temporary_directory, output_dir, dirs_exist_ok=True)
|
|
113
|
+
|
|
114
|
+
if generator == "python":
|
|
115
|
+
bash(f"uv pip install {output_dir.resolve().as_posix()}")
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
# Vibe code: Gemini 3
|
|
2
|
+
# Convert an OpenAPI 3.1.0 schema to a 3.0.3-compatible one in place. openapi-generator
|
|
3
|
+
# only accepts 3.0.x, while Litestar emits 3.1.0. Handles nullable type-arrays, oneOf/anyOf
|
|
4
|
+
# null members, const, exclusive bounds, examples->example, and binary contentEncoding.
|
|
5
|
+
|
|
6
|
+
type JsonPrimitive = str | int | float | bool | None
|
|
7
|
+
type JsonValue = JsonPrimitive | JsonDict | JsonList
|
|
8
|
+
type JsonDict = dict[str, JsonValue]
|
|
9
|
+
type JsonList = list[JsonValue]
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def downgrade_openapi_3_1_to_3_0(schema: JsonDict) -> JsonDict:
|
|
13
|
+
if schema.get("openapi") == "3.1.0":
|
|
14
|
+
schema["openapi"] = "3.0.3"
|
|
15
|
+
|
|
16
|
+
_process_node(schema)
|
|
17
|
+
|
|
18
|
+
return schema
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def _process_node(node: JsonValue) -> None:
|
|
22
|
+
if isinstance(node, dict):
|
|
23
|
+
_convert_dict_node(node)
|
|
24
|
+
for value in node.values():
|
|
25
|
+
_process_node(value)
|
|
26
|
+
elif isinstance(node, list):
|
|
27
|
+
for item in node:
|
|
28
|
+
_process_node(item)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def _convert_dict_node(node: JsonDict) -> None:
|
|
32
|
+
# `type: ["null", "string"]` -> `type: "string", nullable: true`
|
|
33
|
+
type_value = node.get("type")
|
|
34
|
+
if isinstance(type_value, list):
|
|
35
|
+
types: list[str] = [t for t in type_value if isinstance(t, str)]
|
|
36
|
+
has_null = "null" in types
|
|
37
|
+
non_null_types = [t for t in types if t != "null"]
|
|
38
|
+
|
|
39
|
+
if len(non_null_types) == 1:
|
|
40
|
+
node["type"] = non_null_types[0]
|
|
41
|
+
if has_null:
|
|
42
|
+
node["nullable"] = True
|
|
43
|
+
elif len(non_null_types) > 1:
|
|
44
|
+
any_of_items: JsonList = []
|
|
45
|
+
for t in non_null_types:
|
|
46
|
+
item: JsonDict = {"type": t}
|
|
47
|
+
# Array types require items in 3.0.3
|
|
48
|
+
if t == "array":
|
|
49
|
+
item["items"] = {}
|
|
50
|
+
any_of_items.append(item)
|
|
51
|
+
del node["type"]
|
|
52
|
+
node["anyOf"] = any_of_items
|
|
53
|
+
if has_null:
|
|
54
|
+
node["nullable"] = True
|
|
55
|
+
elif has_null and len(non_null_types) == 0:
|
|
56
|
+
# Only null type - use object as fallback
|
|
57
|
+
node["type"] = "object"
|
|
58
|
+
node["nullable"] = True
|
|
59
|
+
|
|
60
|
+
# Ensure array types have items (required in 3.0.3)
|
|
61
|
+
if node.get("type") == "array" and "items" not in node:
|
|
62
|
+
node["items"] = {}
|
|
63
|
+
|
|
64
|
+
# Handle oneOf/anyOf with {"type": "null"}
|
|
65
|
+
for key in ["oneOf", "anyOf"]:
|
|
66
|
+
key_value = node.get(key)
|
|
67
|
+
if isinstance(key_value, list):
|
|
68
|
+
items = key_value
|
|
69
|
+
null_items: list[JsonDict] = [
|
|
70
|
+
item for item in items if isinstance(item, dict) and item.get("type") == "null"
|
|
71
|
+
]
|
|
72
|
+
non_null_items: list[JsonDict] = [
|
|
73
|
+
item for item in items if isinstance(item, dict) and item.get("type") != "null"
|
|
74
|
+
]
|
|
75
|
+
|
|
76
|
+
if null_items:
|
|
77
|
+
node["nullable"] = True
|
|
78
|
+
|
|
79
|
+
if len(non_null_items) == 0:
|
|
80
|
+
# Only had null - remove oneOf/anyOf entirely, set as nullable object
|
|
81
|
+
del node[key]
|
|
82
|
+
if "type" not in node:
|
|
83
|
+
node["type"] = "object"
|
|
84
|
+
elif len(non_null_items) == 1:
|
|
85
|
+
# Single non-null item - inline it and remove oneOf/anyOf
|
|
86
|
+
del node[key]
|
|
87
|
+
single_item = non_null_items[0]
|
|
88
|
+
for k, v in single_item.items():
|
|
89
|
+
if k not in node: # Don't overwrite nullable we just set
|
|
90
|
+
node[k] = v
|
|
91
|
+
else:
|
|
92
|
+
# Multiple non-null items - keep oneOf/anyOf without null
|
|
93
|
+
node[key] = list(non_null_items)
|
|
94
|
+
|
|
95
|
+
# Convert `examples` (3.1.0) to `example` (3.0.3), but only in schema context (no "value" key)
|
|
96
|
+
examples_value = node.get("examples")
|
|
97
|
+
if isinstance(examples_value, list) and len(examples_value) > 0:
|
|
98
|
+
first_example = examples_value[0]
|
|
99
|
+
if not isinstance(first_example, dict) or "value" not in first_example:
|
|
100
|
+
node["example"] = first_example
|
|
101
|
+
del node["examples"]
|
|
102
|
+
|
|
103
|
+
# const (3.1.0) -> enum with a single value (3.0.3)
|
|
104
|
+
if "const" in node:
|
|
105
|
+
node["enum"] = [node["const"]]
|
|
106
|
+
del node["const"]
|
|
107
|
+
|
|
108
|
+
# In 3.1.0 exclusiveMinimum/Maximum are numbers; in 3.0.3 they are booleans paired with minimum/maximum
|
|
109
|
+
exclusive_min = node.get("exclusiveMinimum")
|
|
110
|
+
if isinstance(exclusive_min, (int, float)):
|
|
111
|
+
node["minimum"] = exclusive_min
|
|
112
|
+
node["exclusiveMinimum"] = True
|
|
113
|
+
|
|
114
|
+
exclusive_max = node.get("exclusiveMaximum")
|
|
115
|
+
if isinstance(exclusive_max, (int, float)):
|
|
116
|
+
node["maximum"] = exclusive_max
|
|
117
|
+
node["exclusiveMaximum"] = True
|
|
118
|
+
|
|
119
|
+
# `contentEncoding: "binary"` (3.1) is equivalent to `{type: string, format: binary}` (3.0.3).
|
|
120
|
+
# The containing response's media type already carries the `contentMediaType`, so that field is
|
|
121
|
+
# just dropped.
|
|
122
|
+
if node.get("contentEncoding") == "binary":
|
|
123
|
+
if "format" not in node:
|
|
124
|
+
node["format"] = "binary"
|
|
125
|
+
if "type" not in node:
|
|
126
|
+
node["type"] = "string"
|
|
127
|
+
|
|
128
|
+
# Remove 3.1.0-only properties that aren't supported in 3.0.3
|
|
129
|
+
unsupported_keys = ["contentMediaType", "contentEncoding", "$comment"]
|
|
130
|
+
for key in unsupported_keys:
|
|
131
|
+
if key in node:
|
|
132
|
+
del node[key]
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
from dataclasses import dataclass
|
|
2
|
+
from typing import Protocol
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
@dataclass(frozen=True)
|
|
6
|
+
class ClientNaming:
|
|
7
|
+
base: str
|
|
8
|
+
dashed: str
|
|
9
|
+
underscored: str
|
|
10
|
+
camel: str
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class NamingPolicy(Protocol):
|
|
14
|
+
def __call__(self, project: str) -> ClientNaming: ...
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
@dataclass(frozen=True)
|
|
18
|
+
class DefaultNamingPolicy:
|
|
19
|
+
root_name: str
|
|
20
|
+
|
|
21
|
+
def __call__(self, project: str) -> ClientNaming:
|
|
22
|
+
base = f"{project.rsplit('/', maxsplit=1)[-1]}-client"
|
|
23
|
+
dashed = f"{self.root_name}-{base}"
|
|
24
|
+
underscored = dashed.replace("-", "_")
|
|
25
|
+
camel = f"{self.root_name.capitalize()}{''.join(part.capitalize() for part in base.split('-'))}"
|
|
26
|
+
return ClientNaming(base=base, dashed=dashed, underscored=underscored, camel=camel)
|
|
File without changes
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
|
|
3
|
+
OPENAPI_GENERATOR_CLI_VERSION = "7.22.0"
|
|
4
|
+
|
|
5
|
+
_DATA_DIR = Path(__file__).parent / "_data"
|
|
6
|
+
CONFIGS_DIR = _DATA_DIR / "configs"
|
|
7
|
+
IGNORE_FILE = _DATA_DIR / "openapi-generator-ignore"
|
|
8
|
+
SHIPPED_PATCHES_DIR = _DATA_DIR / "templates-patches" / "csharp"
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
|
|
3
|
+
from bashrun import bash
|
|
4
|
+
|
|
5
|
+
from .resources import OPENAPI_GENERATOR_CLI_VERSION, SHIPPED_PATCHES_DIR
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def regenerate_templates(target_dir: Path, extra_patches_dir: Path | None = None) -> None:
|
|
9
|
+
csharp_target = target_dir / "csharp"
|
|
10
|
+
csharp_target.mkdir(parents=True, exist_ok=True)
|
|
11
|
+
|
|
12
|
+
bash(
|
|
13
|
+
f"uvx --from 'openapi-generator-cli[jdk4py]=={OPENAPI_GENERATOR_CLI_VERSION}' "
|
|
14
|
+
f"openapi-generator-cli author template -g csharp --library httpclient "
|
|
15
|
+
f"-o {csharp_target.resolve().as_posix()}",
|
|
16
|
+
env={"JAVA_OPTS": "-Dlog.level=warn"},
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
patch_directories = [SHIPPED_PATCHES_DIR]
|
|
20
|
+
if extra_patches_dir is not None:
|
|
21
|
+
patch_directories.append(extra_patches_dir)
|
|
22
|
+
|
|
23
|
+
# Patches carry generic `csharp/...` paths; applying with cwd=target_dir and -p1 lands them on
|
|
24
|
+
# the authored tree without needing a surrounding git repository.
|
|
25
|
+
for patch_directory in patch_directories:
|
|
26
|
+
for patch_file in sorted(patch_directory.glob("*.patch")):
|
|
27
|
+
bash(
|
|
28
|
+
f"git apply --ignore-space-change --ignore-whitespace -p1 {patch_file.resolve().as_posix()}",
|
|
29
|
+
cwd=target_dir,
|
|
30
|
+
)
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import json
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
|
|
4
|
+
BASE_REFERENCES = ["Newtonsoft.Json", "Polly", "JsonSubTypes"]
|
|
5
|
+
|
|
6
|
+
# UPM dual of BASE_REFERENCES: the asmdef compiles against the assembly names, the manifest
|
|
7
|
+
# resolves the same runtime support as packages. Newtonsoft maps to the Unity-blessed package
|
|
8
|
+
# instead of the UnityNuGet mirror identity, which collides with the assembly Unity itself
|
|
9
|
+
# provides. Exact versions, not ranges: UPM's package.json dependencies accept SemVer values
|
|
10
|
+
# only — the resolver rejects every range syntax (comparators, x-wildcards) with "Version 'X'
|
|
11
|
+
# is invalid" — and it treats a value as a minimum when resolving, so consumer manifests
|
|
12
|
+
# carrying newer minors still resolve without conflict.
|
|
13
|
+
BASE_DEPENDENCIES = {
|
|
14
|
+
"com.unity.nuget.newtonsoft-json": "3.2.1",
|
|
15
|
+
"org.nuget.polly": "8.1.0",
|
|
16
|
+
"org.nuget.jsonsubtypes": "2.0.1",
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
# The csproj stays in the package (it is the nuget pack input), so MSBuild output is redirected
|
|
20
|
+
# two levels up, outside the package root: bin/obj inside a UPM package lack .meta files (Unity
|
|
21
|
+
# errors on import) and would ride the npm tarball. Two levels up is the client grouping dir in
|
|
22
|
+
# a repo checkout and Unity's Library/ (asset-import-invisible) under PackageCache consumption.
|
|
23
|
+
DIRECTORY_BUILD_PROPS = """<Project>
|
|
24
|
+
<PropertyGroup>
|
|
25
|
+
<BaseIntermediateOutputPath>$(MSBuildThisFileDirectory)../../obj/$(MSBuildProjectName)/</BaseIntermediateOutputPath>
|
|
26
|
+
<BaseOutputPath>$(MSBuildThisFileDirectory)../../bin/$(MSBuildProjectName)/</BaseOutputPath>
|
|
27
|
+
</PropertyGroup>
|
|
28
|
+
</Project>
|
|
29
|
+
"""
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def write_unity_package_metadata(
|
|
33
|
+
package_dir: Path,
|
|
34
|
+
package_name: str,
|
|
35
|
+
extra_references: list[str] | None = None,
|
|
36
|
+
npm_name: str | None = None,
|
|
37
|
+
license_spdx: str | None = None,
|
|
38
|
+
repository_url: str | None = None,
|
|
39
|
+
) -> None:
|
|
40
|
+
references = BASE_REFERENCES if not extra_references else [*BASE_REFERENCES, *extra_references]
|
|
41
|
+
|
|
42
|
+
manifest: dict[str, object] = {
|
|
43
|
+
"name": npm_name if npm_name is not None else f"org.nuget.{package_name.lower()}",
|
|
44
|
+
"displayName": package_name,
|
|
45
|
+
"version": "0.0.0-local",
|
|
46
|
+
"dependencies": BASE_DEPENDENCIES,
|
|
47
|
+
}
|
|
48
|
+
if license_spdx is not None:
|
|
49
|
+
manifest["license"] = license_spdx
|
|
50
|
+
if repository_url is not None:
|
|
51
|
+
manifest["repository"] = {"type": "git", "url": repository_url}
|
|
52
|
+
|
|
53
|
+
(package_dir / "package.json").write_text(json.dumps(manifest, indent=2), encoding="utf-8")
|
|
54
|
+
(package_dir / f"{package_name}.asmdef").write_text(
|
|
55
|
+
json.dumps(
|
|
56
|
+
{
|
|
57
|
+
"name": package_name,
|
|
58
|
+
"references": references,
|
|
59
|
+
"includePlatforms": [],
|
|
60
|
+
"excludePlatforms": [],
|
|
61
|
+
"allowUnsafeCode": False,
|
|
62
|
+
"overrideReferences": False,
|
|
63
|
+
"precompiledReferences": [],
|
|
64
|
+
"autoReferenced": True,
|
|
65
|
+
"defineConstraints": [],
|
|
66
|
+
"versionDefines": [],
|
|
67
|
+
"noEngineReferences": False,
|
|
68
|
+
},
|
|
69
|
+
indent=2,
|
|
70
|
+
),
|
|
71
|
+
encoding="utf-8",
|
|
72
|
+
)
|
|
73
|
+
# Tell the C# compiler to enable nullable annotations
|
|
74
|
+
(package_dir / "csc.rsp").write_text("-nullable:annotations", encoding="utf-8")
|
|
75
|
+
(package_dir / "Directory.Build.props").write_text(DIRECTORY_BUILD_PROPS, encoding="utf-8")
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: openapi-client-codegen
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: OpenAPI client-generation wrapper: Litestar spec dump, 3.1->3.0 downgrade, patched openapi-generator templates, Unity package metadata
|
|
5
|
+
License-File: LICENSE
|
|
6
|
+
License-File: NOTICE
|
|
7
|
+
Requires-Python: >=3.13
|
|
8
|
+
Requires-Dist: bashrun>=0.1.0
|
|
9
|
+
Requires-Dist: typer>=0.17.4
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
openapi_client_codegen/__init__.py,sha256=05SuI_ZEDw6LtioM_7EyY2ji-S8XnxbGxvtXfN0kOKY,453
|
|
2
|
+
openapi_client_codegen/cli.py,sha256=Msvwen2juPp3HyRIvgJuBpEPewty0LfkN0jBk4Og1jA,2317
|
|
3
|
+
openapi_client_codegen/client.py,sha256=9U7-310NYovMm1z7WZ8hGKNOfcY0EzR7BnAQ309wFtM,4633
|
|
4
|
+
openapi_client_codegen/downgrade.py,sha256=7cxQZJRgWR5lNpvyJT-6pg4lVj72LsMRfdYzsNF9DtY,5230
|
|
5
|
+
openapi_client_codegen/naming.py,sha256=c-GmnQk0zb2bsOi0gXOaUD5P_1c-dLfw8FaaNLQxb1I,742
|
|
6
|
+
openapi_client_codegen/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
7
|
+
openapi_client_codegen/resources.py,sha256=Vavy0_zqot1eDrFpDJ_BT4Sbx47vh7zuclPjQtW3QMw,266
|
|
8
|
+
openapi_client_codegen/templates.py,sha256=jixH6nefW58qHGfd5b0QT7fX9z5sHeOd1l5io3i5IxU,1193
|
|
9
|
+
openapi_client_codegen/unity.py,sha256=CLFoNjKJNq-InkaXoqUIJ3q293pWoaLdFNn39D-avgc,3292
|
|
10
|
+
openapi_client_codegen/_data/openapi-generator-ignore,sha256=EckS2MSJlfHzvb6rug11ionYoXnsXSJOkQGdHP6jz98,76
|
|
11
|
+
openapi_client_codegen/_data/configs/csharp.json,sha256=_uezrromftc2dNmDH6JLhKO3MswWXWIesBYOnv8SqFc,587
|
|
12
|
+
openapi_client_codegen/_data/configs/python.json,sha256=Phhny76qY4nVTcdPczBRCn0qgTdsR4WRgjHYslRRxp0,534
|
|
13
|
+
openapi_client_codegen/_data/templates-patches/csharp/0001-csharp-remove-errant-comma.patch,sha256=2AdRZk0L_QXcr08eEzABLBFA-w4er1zGGL_BUbmWojk,952
|
|
14
|
+
openapi_client_codegen/_data/templates-patches/csharp/0002-csharp-models-required-only-constructors.patch,sha256=FrZ1Z1SA9JS1wlYk7h7zFgHNikUcMCWMr5dLhKshykc,5118
|
|
15
|
+
openapi_client_codegen/_data/templates-patches/csharp/0003-csharp-httpclient-use-defaultT.patch,sha256=7DHEQ1yOfg12p7a0b5wJSRGush4ChupB6UNoyilrU9o,851
|
|
16
|
+
openapi_client_codegen/_data/templates-patches/csharp/0004-csharp-support-hybrid-multipart-payloads.patch,sha256=6EvDMYFqNDJsqugLkJFsUjhs8OWOS_dXIhTrcIaH6Pc,8797
|
|
17
|
+
openapi_client_codegen/_data/templates-patches/csharp/0006-csharp-streaming-download-response.patch,sha256=ma-QkJA94jmN3scbJifaVPMcg_NNZ8klVO2HUrLMz_Y,2417
|
|
18
|
+
openapi_client_codegen/_data/templates-patches/csharp/0007-csharp-model-default-initializers.patch,sha256=_fIimm7K0Gh1IYE3_fYyhUom_g-Bm4HlN9jLgsP27IE,862
|
|
19
|
+
openapi_client_codegen/_data/templates-patches/csharp/0008-csharp-redirect-documentation-file.patch,sha256=HQXDgm_CzFYK4oxOoqBkYAz4wrKKPlYpLgTNHI_0IYc,1363
|
|
20
|
+
openapi_client_codegen-0.1.0.dist-info/METADATA,sha256=wqCRN9OSNXcNGMk6KvQrAbQT1HYFslweIfem5fYCmPQ,336
|
|
21
|
+
openapi_client_codegen-0.1.0.dist-info/WHEEL,sha256=W3fkpkm7-wf9vBI5Z-7s0eWkeM-spu78I8Neb98DeEg,87
|
|
22
|
+
openapi_client_codegen-0.1.0.dist-info/entry_points.txt,sha256=mw8FL3PBefHSxRjhBJunBk9G1efUKgxNXwAlghbc31E,74
|
|
23
|
+
openapi_client_codegen-0.1.0.dist-info/licenses/LICENSE,sha256=RFhQPdSOiMTguUX7JSoIuTxA7HVzCbj_p8WU36HjUQQ,10947
|
|
24
|
+
openapi_client_codegen-0.1.0.dist-info/licenses/NOTICE,sha256=jvglZza3GCdN7v4_TLuXUqX9C_uABlwAKUkcIeKwk_8,26
|
|
25
|
+
openapi_client_codegen-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Copyright 2026 Tyler Hatch
|