LuvDaSun / SkiffaGenerator

ISC License
3 stars 2 forks source link

review generated server api #91

Closed elmerbulthuis closed 4 months ago

elmerbulthuis commented 4 months ago

The generated operation handlers are all in the form:

export type OperationHandler<A extends ServerAuthentication> = (
  incomingRequest: OperationIncomingRequest,
  authentication: OperationAuthentication<A>,
  accepts: accept.OperationAccept[],
) => Promise<OutgoingResponse>;

This could be a lot simpler, like this

export type OperationHandler<A extends ServerAuthentication> = (
  parameters: OperationRequestParameters, //optional, only if these are specified
  requestContentType: string, // optional, only if there are possibly more content types
  requestEntity: OperationRequestEntity, // optional, only if there is a request body. This can also be a generator
  authentication: OperationAuthentication<A>, // optional, only present if there is authentication
  accepts: accept.OperationAccept[], // optionally, only if there are multiple reponse types
) => Promise<[
  status: number, // optional, only ifthere
  parameters: OperationResponseParameters, // optional, only if response parameters are specified
  responseContentType: string, // optional, only if multiple response content types are possible
  responseEntity: OperationResponseEntity // optional, only if there is a response body, this can also be a generator.
]>; // if the tuple has only one field, then the return type is just that field.

This will make for a much easier server api.