Skip to content

Pattern fields in Path Item Object are treated as operations #75

Closed
@mastermatt

Description

@mastermatt

My example is Swagger 2, I'm not sure if OpenAPI 3.x specs are affected as well (I only work in Swagger still).

Path Items are able to extend the schema using ^x- fields, docs: https://swagger.io/specification/v2/#patterned-fields-1

Example spec

"paths": {
    "/foo/bar": {
        "x-swagger-router-controller": "foo",
        "get": { ... }
    }
}

Generated Client

export class Api<SecurityDataType = any> extends HttpClient<SecurityDataType> {
  example = {
    /**
     * @name xSwaggerRouterControllerFoo
     * @request X SWAGGER ROUTER CONTROLLER:/foo/bar
     */
    xSwaggerRouterControllerFoo: (params?: RequestParams) =>
      this.request<any, any>(`/foo/bar`, "X SWAGGER ROUTER CONTROLLER", params),
...

Generated Namespace

/**
 * @name xSwaggerRouterControllerFoo
 * @request X SWAGGER ROUTER CONTROLLER:/foo/bar
 */
export namespace XSwaggerRouterControllerFoo {
  export type RequestQuery = {};
  export type RequestBody = never;
  export type ResponseBody = any;
}

The expected behavior is that these extensions would be ignored when collating the operations.

It might be as simple as replacing this omit with a pick and a hard-coded list of verbs.

_.omit(requestInfoByMethodsMap, "parameters"),

But given this comment I didn't presume to open a PR myself.
// TODO: refactor that hell

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions