@@ -56,18 +56,24 @@ func innerCreateProject(ctx *context.APIContext, projectType project_model.Type)
5656}
5757
5858func CreateUserProject (ctx * context.APIContext ) {
59- // swagger:operation POST /user /projects project projectCreateUserProject
59+ // swagger:operation POST /users/{username} /projects project projectCreateUserProject
6060 // ---
6161 // summary: Create a user project
6262 // produces:
6363 // - application/json
6464 // consumes:
6565 // - application/json
6666 // parameters:
67- // - name: project
67+ // - name: username
68+ // in: path
69+ // description: owner of the projects
70+ // type: string
71+ // required: true
72+ // - name: body
6873 // in: body
6974 // required: true
70- // schema: { "$ref": "#/definitions/NewProjectOption" }
75+ // schema:
76+ // "$ref": "#/definitions/NewProjectOption"
7177 // responses:
7278 // "201":
7379 // "$ref": "#/responses/Project"
@@ -92,10 +98,11 @@ func CreateOrgProject(ctx *context.APIContext) {
9298 // description: owner of repo
9399 // type: string
94100 // required: true
95- // - name: project
101+ // - name: body
96102 // in: body
97103 // required: true
98- // schema: { "$ref": "#/definitions/NewProjectOption" }
104+ // schema:
105+ // "$ref": "#/definitions/NewProjectOption"
99106 // responses:
100107 // "201":
101108 // "$ref": "#/responses/Project"
@@ -125,10 +132,11 @@ func CreateRepoProject(ctx *context.APIContext) {
125132 // description: repo
126133 // type: string
127134 // required: true
128- // - name: project
135+ // - name: body
129136 // in: body
130137 // required: true
131- // schema: { "$ref": "#/definitions/NewProjectOption" }
138+ // schema:
139+ // "$ref": "#/definitions/NewProjectOption"
132140 // responses:
133141 // "201":
134142 // "$ref": "#/responses/Project"
@@ -146,7 +154,7 @@ func GetProject(ctx *context.APIContext) {
146154 // produces:
147155 // - application/json
148156 // parameters:
149- // - name: id
157+ // - name: project_id
150158 // in: path
151159 // description: id of the project
152160 // type: string
@@ -158,7 +166,7 @@ func GetProject(ctx *context.APIContext) {
158166 // "$ref": "#/responses/forbidden"
159167 // "404":
160168 // "$ref": "#/responses/notFound"
161- project , err := project_model .GetProjectByID (ctx , ctx .FormInt64 ("project_id" ))
169+ project , err := project_model .GetProjectByID (ctx , ctx .PathParamInt64 ("project_id" ))
162170 if err != nil {
163171 if project_model .IsErrProjectNotExist (err ) {
164172 ctx .APIError (http .StatusNotFound , err )
@@ -168,6 +176,8 @@ func GetProject(ctx *context.APIContext) {
168176 return
169177 }
170178
179+ // TODO: permission check
180+
171181 projectResponse , err := convert .ToAPIProject (ctx , project )
172182 if err != nil {
173183 ctx .APIErrorInternal (err )
@@ -185,15 +195,16 @@ func UpdateProject(ctx *context.APIContext) {
185195 // consumes:
186196 // - application/json
187197 // parameters:
188- // - name: id
198+ // - name: project_id
189199 // in: path
190200 // description: id of the project
191201 // type: string
192202 // required: true
193203 // - name: project
194204 // in: body
195205 // required: true
196- // schema: { "$ref": "#/definitions/UpdateProjectOption" }
206+ // schema:
207+ // "$ref": "#/definitions/UpdateProjectOption"
197208 // responses:
198209 // "200":
199210 // "$ref": "#/responses/Project"
@@ -202,7 +213,7 @@ func UpdateProject(ctx *context.APIContext) {
202213 // "404":
203214 // "$ref": "#/responses/notFound"
204215 form := web .GetForm (ctx ).(* api.UpdateProjectOption )
205- project , err := project_model .GetProjectByID (ctx , ctx .FormInt64 ("project_id" ))
216+ project , err := project_model .GetProjectByID (ctx , ctx .PathParamInt64 ("project_id" ))
206217 if err != nil {
207218 if project_model .IsErrProjectNotExist (err ) {
208219 ctx .APIError (http .StatusNotFound , err )
@@ -218,6 +229,8 @@ func UpdateProject(ctx *context.APIContext) {
218229 project .Description = form .Body
219230 }
220231
232+ // TODO: permission check
233+
221234 err = project_model .UpdateProject (ctx , project )
222235 if err != nil {
223236 ctx .APIErrorInternal (err )
@@ -236,7 +249,7 @@ func DeleteProject(ctx *context.APIContext) {
236249 // ---
237250 // summary: Delete project
238251 // parameters:
239- // - name: id
252+ // - name: project_id
240253 // in: path
241254 // description: id of the project
242255 // type: string
@@ -249,7 +262,9 @@ func DeleteProject(ctx *context.APIContext) {
249262 // "404":
250263 // "$ref": "#/responses/notFound"
251264
252- if err := project_model .DeleteProjectByID (ctx , ctx .FormInt64 ("project_id" )); err != nil {
265+ // TODO: permission check
266+
267+ if err := project_model .DeleteProjectByID (ctx , ctx .PathParamInt64 ("project_id" )); err != nil {
253268 ctx .APIErrorInternal (err )
254269 return
255270 }
@@ -258,12 +273,17 @@ func DeleteProject(ctx *context.APIContext) {
258273}
259274
260275func ListUserProjects (ctx * context.APIContext ) {
261- // swagger:operation GET /users/{user }/projects project projectListUserProjects
276+ // swagger:operation GET /users/{username }/projects project projectListUserProjects
262277 // ---
263278 // summary: List user projects
264279 // produces:
265280 // - application/json
266281 // parameters:
282+ // - name: username
283+ // in: path
284+ // description: owner of the projects
285+ // type: string
286+ // required: true
267287 // - name: closed
268288 // in: query
269289 // description: include closed projects or not
@@ -288,7 +308,7 @@ func ListUserProjects(ctx *context.APIContext) {
288308 projects , count , err := db .FindAndCount [project_model.Project ](ctx , project_model.SearchOptions {
289309 Type : project_model .TypeIndividual ,
290310 IsClosed : ctx .FormOptionalBool ("closed" ),
291- OwnerID : ctx .Doer .ID ,
311+ OwnerID : ctx .ContextUser .ID ,
292312 ListOptions : listOptions ,
293313 })
294314 if err != nil {
0 commit comments