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

[Bug]: Unable to model Polymorphic properties in ARM Patch SYnc #5436

Open
4 tasks done
Abhinav93 opened this issue Dec 24, 2024 · 0 comments
Open
4 tasks done

[Bug]: Unable to model Polymorphic properties in ARM Patch SYnc #5436

Abhinav93 opened this issue Dec 24, 2024 · 0 comments
Labels
bug Something isn't working needs-area

Comments

@Abhinav93
Copy link

Describe the bug

We have some polymorphic discriminator properties in our typespec. One of the examples beloe

// Polymorphic Source
@discriminator("type")
@doc("The type of backing data source")
model Source {
  @doc("Type of the Storage Connector – Bucket. Not mutable once the Storage Connector is created.")
  type?: SourceType;
}
// Bucket source extends source
@doc("The properties of the backing data store.")
model BucketSource extends Source {
  @visibility("read")
  type: SourceType.Bucket;
  @doc("Details for how to connect to the backing data store.")
  connection: Connection;
  @doc("Details for how to authenticate to the backing data store.")
  authProperties: AuthProperties;
  @doc("The host to use when computing the signature for requests to the backing data store. If not provided, defaults to what is provided in the endpoint for the connection.")
  hostOverride?: string;
}
// The actual connector properties 
@doc("Details of the Storage Connector.")
model ConnectorProperties {
  @visibility("read", "create")
  @doc("System-generated identifier for the Storage Connector. Not a valid input parameter when creating.")
  uniqueId?: string;
  @doc("State – Enabled or Disabled. Whether or not the Storage Connector should start as enabled (default: Enabled) (While set to false on the Storage Connector, all data plane requests using this Storage Connector fail, and this Storage Connector is not billed if it would be otherwise.)")
  state?: State = State.Enabled;
  @visibility("read", "create")
  @doc("System-generated creation time for the Storage Connector. Not a valid input parameter when creating.")
  creationTime?: string;
  @doc("Arbitrary description of this Storage Connector. Max 250 characters.")
  @maxLength(250)
  description?: string;
  @doc("Information about how to communicate with and authenticate to the backing data store.")
  source: Source;
  @visibility("read")
  @doc("The status of the last operation.")
  provisioningState?: ProvisioningState;
}
// Conenctor resource as tarcked resource
@doc("A Connector is a tracked ARM resource modeled as a sub-resource of a Storage Account")
model Connector is TrackedResource<ConnectorProperties> {
  @doc("The name of the connector")
  @pattern("^[a-zA-Z0-9-]{3,24}$")
  @key("connectorName")
  @segment("connectors")
  @path
  name: string;
}
When adding a update patch method for this resource -
@armResourceOperations(Connector)
interface Connectors {
  @doc("Get the specified Storage Connector.")
  get is ArmResourceRead<Connector>;
  @doc("Create or update a Storage Connector.")
  createOrReplace is ArmResourceCreateOrReplaceAsync<Connector>;
  @doc("Update a Storage Connector.")
  update is ArmCustomPatchAsync<
    Connector,
    ConnectorProperties
    >;
}

We see an error from swagger Lint DIff validation stating that all properties of a patch resource should be optional.
Typespec does not allow us to have optional discriminator values
Is there a way we can model this in typespec for patch api?

Reproduction

Model the above in typesepc with ARM patch sync to reproduce this error

Checklist

@Abhinav93 Abhinav93 added the bug Something isn't working label Dec 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs-area
Projects
None yet
Development

No branches or pull requests

1 participant