dtsgenerator icon indicating copy to clipboard operation
dtsgenerator copied to clipboard

Add operationId as part of Paths

Open henhal opened this issue 3 years ago • 1 comments

In some situations it might be useful to include the operationId of each operation in the generated types, as a const ID value.

For example I'm considering writing a dtsgen plugin that emits a map of operationId to request body+response body types, but when the plugin is invoked, the operationId is gone.

Example:

  /foo:
    post:
      operationId: addFoo
      ...

Current generated type:

    namespace AddFoo {
        export interface HeaderParameters {
        }
        namespace Parameters {
        }
        export type RequestBody = ...
        namespace Responses {
            export interface $200 {
                ...
            }
        }
    }

Suggested:

    namespace AddFoo {
        export const ID = 'addFoo';
        export interface HeaderParameters {
        }
        namespace Parameters {
        }
        export type RequestBody = ...
        namespace Responses {
            export interface $200 {
            }
        }
    }

An even more powerful solution might be to include the original JSON schema as part of the context passed to plugins, if possible, then plugins would be able to do more advanced tweaking of the output also using data from the input schema.

henhal avatar Sep 15 '20 07:09 henhal

This is the kind of content that a plugin would be suited for.

horiuchi avatar Dec 25 '20 08:12 horiuchi