-
-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Nullable Strings not being marked correctly #580
Comments
@JamesFieldist Thanks for taking the time to report this Refitter uses NSwag for parsing the OpenAPI document and for generating the contracts. If NSwag can do this out-of-the-box then I need to align how Refitter uses NSwag with that behavior. Let me see what I can do. Refitter caters to quite a number of users which have introduced multiple options for generating contracts Do you use NSwag from the desktop app or CLI? Do you mind sharing the options you use with NSwag? |
nswag openapi2csclient /input:your-schema.json /output:Client.cs /nullableReferenceTypes:true /generateNullableProperties:true Although there seems to be some claims that you have to use nullable:true in the openapi.json documentation file, but it looks like that was fixed? |
@JamesFieldist Sorry, I just overlooked that the Try creating a {
"openApiPath": "https://localhost:15159/help/v1/openapi.json",
"namespace": "TestClient.Interfaces",
"contractsNamespace": "TestClient.Contracts",
"trimUnusedSchema": true,
"immutableRecords": true,
"useCancellationTokens": true,
"generateMultipleFiles": true,
"generateDeprecatedOperations": false,
"codeGeneratorSettings": {
"generateOptionalPropertiesAsNullable": true,
"generateNullableReferenceTypes": true
}
} then run Refitter with the following arguments
The .refitter file format is described in https://refitter.github.io/articles/refitter-file-format.html |
Describe the bug
Nullable strings in the openapi.json marked correctly are not being made string? in contracts.
Consider the following openapi.json snippet:
This produces this C#:
Note that Street2 is not marked as string? etc. Only the doubles are.
And that's using the following:
dotnet tool run refitter https://localhost:15159/help/v1/openapi.json --output ./ --namespace TestClient.Interfaces --contracts-namespace TestClient.Contracts --trim-unused-schema --immutable-records --cancellation-tokens --multiple-files --no-deprecated-operations --optional-nullable-parameters --nullable-reference-types --disposable
This should have produced nullable string values.
Support Key:
[my-support-key]
lxoej4f
Additional context
This appears to only be a problem with strings. nswag does this correctly from the definition provided.
The text was updated successfully, but these errors were encountered: