Skip to content
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

Base type not generated for types specified by oneOf in the schema #175

Open
attilah opened this issue Oct 5, 2023 · 2 comments
Open

Base type not generated for types specified by oneOf in the schema #175

attilah opened this issue Oct 5, 2023 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@attilah
Copy link

attilah commented Oct 5, 2023

Describe the bug
I try to generate a client for the FusionAuth spec and it is using oneOf for IdentityProviderField and in the resulting source file no IdentityProvider base class is generated.

Support Key: [my-support-key]
N/A (did not find it in output)

OpenAPI Specifications
https://raw.githubusercontent.com/FusionAuth/fusionauth-openapi/main/openapi.yaml

Additional context
My quick fix were these:

  1. Create an IdentityProvider class:
public class IdentityProvider
{
}
  1. Change the method response to have a generic parameter:
    public partial class IdentityProviderResponse<T> where T: IdentityProvider
    {

        [JsonPropertyName("identityProvider")]

        [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]   
        public T IdentityProvider { get; set; }

        [JsonPropertyName("identityProviders")]

        [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]   
        public ICollection<T> IdentityProviders { get; set; }

        private IDictionary<string, object> _additionalProperties;

        [JsonExtensionData]
        public IDictionary<string, object> AdditionalProperties
        {
            get { return _additionalProperties ?? (_additionalProperties = new Dictionary<string, object>()); }
            set { _additionalProperties = value; }
        }
    }
  1. Change the method signature:
Task<IdentityProviderResponse<T>> RetrieveIdentityProviderWithIdAsync<T>(string identityProviderId, CancellationToken cancellationToken = default) where T : IdentityProvider;
@attilah attilah added the bug Something isn't working label Oct 5, 2023
@christianhelle
Copy link
Owner

@attilah thanks for taking the time to report this. I'll see what I can do

@christianhelle
Copy link
Owner

@attilah The contract/dto types generated are partial classes. Would it help extending those? I piggy back on NSwag for contract/dto type generation and there is very little I can do to change how things these types are generated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants