Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for @kok(alias) #11

Closed
RussellLuo opened this issue Jun 29, 2021 · 0 comments
Closed

Add support for @kok(alias) #11

RussellLuo opened this issue Jun 29, 2021 · 0 comments

Comments

@RussellLuo
Copy link
Owner

Lengthy

type User interface {
    // @kok(op): POST /users
    // @kok(param): operatorID < in:header,name:Authorization,required:true
    Create(ctx context.Context, operatorID int) (err error)

    // @kok(op): GET /users/{id}
    // @kok(param): operatorID < in:header,name:Authorization,required:true
    Read(ctx context.Context, id, operatorID int) (err error)

    // @kok(op): PUT /users/{id}
    // @kok(param): operatorID < in:header,name:Authorization,required:true
    Update(ctx context.Context, id, operatorID int) (err error)

    // @kok(op): DELETE /users/{id}
    // @kok(param): operatorID < in:header,name:Authorization,required:true
    Delete(ctx context.Context, id, operatorID int) (err error)
}

Simplified

// @kok(alias): auth=`in:header,name:Authorization,required:true`
type User interface {
    // @kok(op): POST /users
    // @kok(param): operatorID < $auth
    Create(ctx context.Context, operatorID int) (err error)

    // @kok(op): GET /users/{id}
    // @kok(param): operatorID < $auth
    Read(ctx context.Context, id, operatorID int) (err error)

    // @kok(op): PUT /users/{id}
    // @kok(param): operatorID < $auth
    Update(ctx context.Context, id, operatorID int) (err error)

    // @kok(op): DELETE /users/{id}
    // @kok(param): operatorID < $auth
    Delete(ctx context.Context, id, operatorID int) (err error)
}

Or

// @kok(alias): opID=`operatorID < in:header,name:Authorization,required:true`
type User interface {
    // @kok(op): POST /users
    // @kok(param): $opID
    Create(ctx context.Context, operatorID int) (err error)

    // @kok(op): GET /users/{id}
    // @kok(param): $opID
    Read(ctx context.Context, id, operatorID int) (err error)

    // @kok(op): PUT /users/{id}
    // @kok(param): $opID
    Update(ctx context.Context, id, operatorID int) (err error)

    // @kok(op): DELETE /users/{id}
    // @kok(param): $opID
    Delete(ctx context.Context, id, operatorID int) (err error)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant