Skip to content

code gen should generate controller constructor that returns concret type instead of interface #416

@TimShi

Description

@TimShi

Description

Expected Behavior

It should generate constructor that returns the concrete type that implements this interface

func NewExampleFriendsController(r *repository.FriendsRepository) *ExampleFriendsController {

Actual Behavior

Currently, code gen generates controller constructor that returns web.Controller interface.

func NewExampleFriendsController(di exampleFriendsControllerDI) web.Controller {

This makes it hard to inject this specific controller instance into test if there are multiple controllers in the test.

Affected Version

v0.14.0

Steps to Reproduce

Follow the README in examples/database to generate the service based on contract.

Checklist

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions