Interface IHttpMigrateRoute

Route information for migration.

The IHttpMigrateRoute is a structure representing a route information for OpenAPI generator libraries, which composes an RPC (Remote Procedure Call) function from the OpenAPI operation.

As the IHttpMigrateRoute has a lot of special stories, when you're developing OpenAPI generator library, please read its description carefully including the description of its properties.

Jeongho Nam - https://github.com/samchon

interface IHttpMigrateRoute {
    accessor: string[];
    body: null | IBody;
    comment: () => string;
    emendedPath: string;
    exceptions: Record<string, IException>;
    headers: null | IHeaders;
    method: "get" | "post" | "put" | "delete" | "head" | "patch";
    operation: () => OpenApi.IOperation;
    parameters: IHttpMigrateRoute.IParameter[];
    path: string;
    query: null | IQuery;
    success: null | IHttpMigrateRoute.ISuccess;
}

Properties

accessor: string[]

Accessor for the route.

The accessor is a list of string values that are representing how to access to the OpenAPI generated RPC (Remote Procedure Call) function through namespace(s).

The accessor is composed with the following rules. At first, namespaces are composed by static directory names in the path. Parametric symbols represented by :param or {param} cannot be a part of the namespace.

Instead, they would be a part of the function name. The function name is composed with the HTTP method and parametric symbols like getByParam or postByParam. If there are multiple path parameters, they would be concatenated by And like getByParam1AndParam2.

For refefence, if the operation's method is delete, the function name would be replaced to erase instead of delete. It is the reason why the delete is a reserved keyword in many programming languages.

  • Example 1
    • path: POST /shopping/sellers/sales
    • accessor: shopping.sellers.sales.post
  • Example 2
    • endpoint: `GET /shoppings/sellers/sales/:saleId/reviews/:reviewId/comments/:id
    • accessor: shoppings.sellers.sales.reviews.getBySaleIdAndReviewIdAndCommentId
body: null | IBody

Metadata of request body.

The body property is a metadata of HTTP request body for RPC function, including the parameter variable name, content type, and schema.

If the body property is null, it means the operation does not require the request body data.

comment: () => string

Description comment for the route function.

The comment is a function returning description comment for the RPC function of OpenAPI generated. The comment is composed with the following rules:

  1. Starts from the OpenApi.IOperation.summary paragraph.
  2. The next paragraphs are filled with OpenApi.IOperation.description.
  3. Parameter descriptions are added with @param tag.
  4. Security requirements are added with @security tag.
  5. Tag names are added with @tag tag.
  6. If OpenApi.IOperation.deprecated, @deprecated tag is added.
emendedPath: string

Emended path for OpenAPI generator libraries.

The difference between path is:

  1. Path parameters are replaced with :param format.
  2. Empty sub-paths are removed.
  3. Do not starts with /.
exceptions: Record<string, IException>

Metadata of response body for exceptional status cases.

The exceptions property is a metadata of HTTP response body for RPC function, including content type, and schema when status code is not 200 or 201.

The key of the exceptions property is the status code. It may be a stringified number, but sometimes it could be a string like "default", because the OpenAPI document allows the status code to be a string.

headers: null | IHeaders

Metadata of headers.

The headers property is a metadata of HTTP request headers for RPC function, including the parameter variable name and schema.

Also, its IHttpMigrateRoute.IHeaders.schema is always object or reference to object. Even though the original OpenAPI operation's headers are separated to atomic typed properties, the headers property forcibly combines them into a single object type.

For reference, if the headers property has been converted to an object type forcibly, its property name and key are always "headers".

method: "get" | "post" | "put" | "delete" | "head" | "patch"

Method of the route.

If the OpenApi.IOperation.method is not one of below type values, the operation would be ignored in the migration process for the RPC (Remote Procedure Call) function.

operation: () => OpenApi.IOperation

Original operation from the OpenAPI document.

The operation is a function returning the original OpenApi.IOperation from the OpenAPI document.

List of path parameters.

Note that, not a list of every parameters, but only path parameters.

path: string

Original path from the OpenAPI document.

query: null | IQuery

Metadata of query values.

The query property is a metadata of HTTP request query values for RPC function, including the parameter variable name and schema.

Also, its IHttpMigrateRoute.IQuery.schema is always object or reference to object. Even though the original OpenAPI operation's query parameters are separated to atomic typed properties, the query property forcibly combines them into a single object type.

For reference, if the query property has been converted to an object type forcibly, its property name and key are always "headers".

success: null | IHttpMigrateRoute.ISuccess

Metadata of response body for success case.

The success property is a metadata of HTTP response body for RPC function, including content type, and schema when status code is 200 or 201.

If the success property is null, it means the operation does not have the response body data. In other words, the RPC function would return void.