@@ -65,6 +65,7 @@ private static void ProcessDatasyncOperation(OperationProcessorContext context)
6565 string path = context . OperationDescription . Path ;
6666 Type entityType = GetTableEntityType ( context . ControllerType ) ;
6767 JsonSchema entitySchemaRef = GetEntityReference ( context , entityType ) ;
68+ AddMissingSchemaProperties ( entitySchemaRef . Reference ) ;
6869
6970 if ( method . Equals ( "DELETE" , StringComparison . InvariantCultureIgnoreCase ) )
7071 {
@@ -91,20 +92,59 @@ private static void ProcessDatasyncOperation(OperationProcessorContext context)
9192 if ( method . Equals ( "POST" , StringComparison . InvariantCultureIgnoreCase ) )
9293 {
9394 operation . AddConditionalRequestSupport ( entitySchemaRef , true ) ;
95+ operation . TryAddConsumes ( "application/json" ) ;
96+ operation . Parameters . Add ( new OpenApiParameter { Schema = entitySchemaRef , Kind = OpenApiParameterKind . Body } ) ;
9497 operation . SetResponse ( HttpStatusCode . Created , entitySchemaRef ) ;
9598 operation . SetResponse ( HttpStatusCode . BadRequest ) ;
9699 }
97100
98101 if ( method . Equals ( "PUT" , StringComparison . InvariantCultureIgnoreCase ) )
99102 {
100103 operation . AddConditionalRequestSupport ( entitySchemaRef ) ;
104+ operation . TryAddConsumes ( "application/json" ) ;
105+ operation . Parameters . Add ( new OpenApiParameter { Schema = entitySchemaRef , Kind = OpenApiParameterKind . Body } ) ;
101106 operation . SetResponse ( HttpStatusCode . OK , entitySchemaRef ) ;
102107 operation . SetResponse ( HttpStatusCode . BadRequest ) ;
103108 operation . SetResponse ( HttpStatusCode . NotFound ) ;
104109 operation . SetResponse ( HttpStatusCode . Gone ) ;
105110 }
106111 }
107112
113+ private static void AddMissingSchemaProperties ( JsonSchema ? schema )
114+ {
115+ if ( schema is null )
116+ {
117+ return ;
118+ }
119+
120+ if ( schema . Properties . ContainsKey ( "id" ) && schema . Properties . ContainsKey ( "updatedAt" ) && schema . Properties . ContainsKey ( "version" ) )
121+ {
122+ // Nothing to do - the correct properties are already in the schma.
123+ return ;
124+ }
125+
126+ _ = schema . Properties . TryAdd ( "id" , new JsonSchemaProperty
127+ {
128+ Type = JsonObjectType . String ,
129+ Description = "The globally unique ID for the entity" ,
130+ IsRequired = true
131+ } ) ;
132+ _ = schema . Properties . TryAdd ( "updatedAt" , new JsonSchemaProperty
133+ {
134+ Type = JsonObjectType . String ,
135+ Description = "The ISO-8601 date/time string describing the last time the entity was updated with ms accuracy." ,
136+ IsRequired = false
137+ } ) ;
138+ _ = schema . Properties . TryAdd ( "version" , new JsonSchemaProperty
139+ {
140+ Type = JsonObjectType . String ,
141+ Description = "An opaque string that changes whenever the entity changes." ,
142+ IsRequired = false
143+ } ) ;
144+
145+ return ;
146+ }
147+
108148 /// <summary>
109149 /// Either reads or generates the required entity type schema.
110150 /// </summary>
0 commit comments