You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the eventgrid_modular, test case,
we have a CloudEvent model. it's looking like
/** Properties of an event published to an Azure Messaging EventGrid Namespace topic using the CloudEvent 1.0 Schema. */exportinterfaceCloudEvent{/** An identifier for the event. The combination of id and source must be unique for each distinct event. */id: string;/** Identifies the context in which an event happened. The combination of id and source must be unique for each distinct event. */source: string;/** Event data specific to the event type. */data?: any;/** Event data specific to the event type, encoded as a base64 string. */dataBase64?: Uint8Array;/** Type of event related to the originating occurrence. */type: string;/** The time (in UTC) the event was generated, in RFC3339 format. */time?: Date;/** The version of the CloudEvents specification which the event uses. */specversion: string;/** Identifies the schema that data adheres to. */dataschema?: string;/** Content type of data value. */datacontenttype?: string;/** This describes the subject of the event in the context of the event producer (identified by source). */subject?: string;}
here we are using the dataBase64 as the property name. But in the rest layer,
/** Properties of an event published to an Azure Messaging EventGrid Namespace topic using the CloudEvent 1.0 Schema. */exportinterfaceCloudEvent{/** An identifier for the event. The combination of id and source must be unique for each distinct event. */id: string;/** Identifies the context in which an event happened. The combination of id and source must be unique for each distinct event. */source: string;/** Event data specific to the event type. */data?: unknown;/** Event data specific to the event type, encoded as a base64 string. */data_base64?: string;/** Type of event related to the originating occurrence. */type: string;/** The time (in UTC) the event was generated, in RFC3339 format. */time?: Date|string;/** The version of the CloudEvents specification which the event uses. */specversion: string;/** Identifies the schema that data adheres to. */dataschema?: string;/** Content type of data value. */datacontenttype?: string;/** This describes the subject of the event in the context of the event producer (identified by source). */subject?: string;}
the property name is data_base64, and in the send function, we just assign the modular layer model CloudEvent to the rest layer model
The reason it could build now, it's because the dataBase64 and data_base64 property are optional.
We should add an internal serialize function for each modular api if there's some propery rename and type mapping.
In this case, there's still another issue,
In the serialize we need to convert the Unit8Array into string.
And in the deserialize, we need to convert the string into Uint8Array.
Another question need to mention is that although the property name and description says it's base64 encoded, its typespec doesn't really add this information.
@doc("Event data specific to the event type, encoded as a base64 string.")data_base64?: bytes;
if we want to test against base64 encoding, we should define a property like
@doc("Event data specific to the event type, encoded as a base64 string.")
@encode("base64")
data_base64?: bytes;
The text was updated successfully, but these errors were encountered:
Partially fixAzure/autorest.typescript#1933
Add some helper function in core-util to support converter from bytes
array to string with different kinds of character encoding. Currently
only support base64 and utf-8 and base64url. which should be able to
work in both Node environment and browser environment.
We will need to wait for typespec team's response to see if we need to
support more. issue tracked here
microsoft/typespec#2204
---------
Co-authored-by: Jeff Fisher <xirzec@xirzec.com>
In the eventgrid_modular, test case,
we have a CloudEvent model. it's looking like
here we are using the dataBase64 as the property name. But in the rest layer,
the property name is data_base64, and in the send function, we just assign the modular layer model CloudEvent to the rest layer model
The reason it could build now, it's because the dataBase64 and data_base64 property are optional.
We should add an internal serialize function for each modular api if there's some propery rename and type mapping.
In this case, there's still another issue,
In the serialize we need to convert the Unit8Array into string.
And in the deserialize, we need to convert the string into Uint8Array.
Another question need to mention is that although the property name and description says it's base64 encoded, its typespec doesn't really add this information.
if we want to test against base64 encoding, we should define a property like
The text was updated successfully, but these errors were encountered: