livebud / livebud/bud

How to change default id:int to name:string in generated url path?

Open
#363 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug help wanted improvement
Dominant language
JavaScript
Stars
5.6k
Forks
175
PR merge metrics
No merged PRs in 30d

Description

First of all thank you very much for the tool, very useful.
I have some questions waiting for your help.

1. how to change id:int to name:string?

If I run the following commands to generate controller and view, I got a generated path like // GET /pscluster/:pscluster_id/psmeta/:id. Do we have some cli flags to change ":pscluter_id int" to ":pscluster_name string"?

bud new controller pscluster index new create show edit update delete
bud new controller pscluster/psmeta create show edit update delete


// GET /pscluster/:pscluster_id/psmeta/:id

2. why this strange name generated?

when I run bud new controller pscluster/psmeta create show edit update delete, I got a strange struct name, which change psmeta to psmetum

// Psmetum struct
type Psmetum struct {
	ID int `json:"id"`
}

// Create psmetum
// POST /pscluster/:pscluster_id/psmeta
func (c *Controller) Create(ctx context.Context) (psmetum *Psmetum, err error) {
	return &Psmetum{
		ID: 0,
	}, nil
}

3. Underscores become dashes in url

bud new controller ps_cluster index new create show edit update delete
// GET /ps-cluster

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the bud new controller CLI entry point and trace controller, route, and model-name generation for nested resources. Check how pscluster/psmeta and ps_cluster are transformed, then inspect any generator tests. Done means the supported customization behavior is documented or the generated names and paths match the intended forms.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
backend, cli
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.