Skip to content

Feat | API OAuth2UserApiController routes v1#106

Open
matiasperrone-exo wants to merge 2 commits intomainfrom
feat/openapi----api-v1---oauth2userapicontroller
Open

Feat | API OAuth2UserApiController routes v1#106
matiasperrone-exo wants to merge 2 commits intomainfrom
feat/openapi----api-v1---oauth2userapicontroller

Conversation

@matiasperrone-exo
Copy link
Contributor

@matiasperrone-exo matiasperrone-exo commented Feb 11, 2026

Task:

Ref: https://app.clickup.com/t/86b8e6k87

Endpoints:

Method Endpoint Method Name
GET,HEAD api/v1/users getAll
POST api/v1/users create
GET,HEAD api/v1/users/info userInfo
POST api/v1/users/info userInfo
GET,HEAD api/v1/users/me me
OPTIONS,PUT api/v1/users/me updateMe
OPTIONS,PUT api/v1/users/me/pic updateMyPic
GET,HEAD api/v1/users/{id} get
PUT api/v1/users/{id} update
PUT api/v1/users/{id}/groups updateUserGroups

Summary by CodeRabbit

  • New Features
    • Added multiple new API endpoints for user management: creating users, updating user information, managing profile pictures, and assigning users to groups.
    • Introduced comprehensive OpenAPI documentation for user endpoints with security scopes and detailed request/response schemas.

@matiasperrone-exo matiasperrone-exo self-assigned this Feb 11, 2026
@matiasperrone-exo matiasperrone-exo added the documentation Improvements or additions to documentation label Feb 11, 2026
@matiasperrone-exo matiasperrone-exo force-pushed the feat/openapi----api-v1---oauth2userapicontroller branch from e5e28a9 to 54025c8 Compare February 11, 2026 22:36
@smarcet smarcet force-pushed the main branch 2 times, most recently from ae79f5e to 4b5b726 Compare February 12, 2026 20:00
@matiasperrone-exo matiasperrone-exo force-pushed the feat/openapi----api-v1---oauth2userapicontroller branch 9 times, most recently from ebfe31c to 28e31ae Compare February 13, 2026 20:34
@matiasperrone-exo matiasperrone-exo force-pushed the feat/openapi----api-v1---oauth2userapicontroller branch from 28e31ae to 2c37852 Compare February 13, 2026 20:43
Copy link

@martinquiroga-exo martinquiroga-exo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@matiasperrone-exo please add the clickup card link to this PR please

Copy link
Contributor

@caseylocker caseylocker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@coderabbitai
Copy link

coderabbitai bot commented Mar 14, 2026

📝 Walkthrough

Walkthrough

This pull request introduces comprehensive OpenAPI documentation and exposes new REST API endpoints in OAuth2UserApiController. Eight new Swagger schema classes are added to define request payloads, response structures, and security configurations. The existing controller logic remains unchanged; new public methods and routes surface previously internal functionality through enhanced HTTP method bindings and security scope annotations.

Changes

Cohort / File(s) Summary
Controller Enhancement
app/Http/Controllers/Api/OAuth2/OAuth2UserApiController.php
Adds 413 lines of OpenAPI annotations and exposes new endpoints for user listing, creation, updates, profile picture uploads, and group assignments. Introduces public methods: create(), updateMyPic(), updateUserGroups(), and get() with v1/v2 route variants. Preserves existing error handling paths and internal logic.
OpenAPI Response Schemas
app/Swagger/Models/UserInfoResponseSchema.php, app/Swagger/OAuth2UserApiControllerSchemas.php
Defines UserInfoResponseSchema with OpenID Connect claims (address, email, profile, group references) and PaginatedUserResponseSchema combining pagination metadata with User array data.
OpenAPI Request Schemas
app/Swagger/Requests/CreateUserRequestSchema.php, app/Swagger/Requests/UpdateUserRequestSchema.php, app/Swagger/Requests/UpdateUserPicRequestSchema.php, app/Swagger/Requests/UpdateUserGroupsRequestSchema.php, app/Swagger/Requests/UserFieldsSchema.php
Introduces five schema classes defining request structures: user creation (email required), user updates (all fields optional), profile picture uploads (binary file), group assignment (integer array), and reusable UserFields component with 30+ properties covering personal info, contact, address, professional, social media, and security fields.
OpenAPI Security Schema
app/Swagger/Security/UsersOAuth2Schema.php
Defines user_oauth2 security scheme with authorizationCode flow, scopes mapped from IUserScopes (Profile, Email, Address, ReadAll, MeWrite, Write, UserGroupWrite).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Poem

🐰 Hippity-hop through API flows so grand,
New endpoints bloom across the land,
OpenAPI schemas neat and tight,
Security scopes shining bright!
Documentation blooms, users unified—
The REST is blessed!

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 30.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Feat | API OAuth2UserApiController routes v1' clearly relates to the main change—adding v1 API routes for OAuth2UserApiController with OpenAPI annotations.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/openapi----api-v1---oauth2userapicontroller
📝 Coding Plan
  • Generate coding plan for human review comments

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link

📘 OpenAPI / Swagger preview

➡️ https://OpenStackweb.github.io/openstackid/openapi/pr-106/

This page is automatically updated on each push to this PR.

#[
OA\SecurityScheme(
type: 'oauth2',
securityScheme: 'user_oauth2',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@matiasperrone-exo this security schema dupes the one defined at PR 105 ( OAuth2UserSecurity) please review and unify schemas ( use OAuth2UserSecurity )

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@app/Http/Controllers/Api/OAuth2/OAuth2UserApiController.php`:
- Around line 499-504: The OpenAPI response for the update operation in
OAuth2UserApiController currently uses HttpResponse::HTTP_CREATED (201); change
it to HttpResponse::HTTP_OK (200) so the OA\Response for the update (the block
creating new OA\Response in OAuth2UserApiController, around the
profile-picture/update endpoint) correctly reflects an update operation
returning 200 instead of 201.
- Around line 801-805: The OpenAPI annotation in OAuth2UserApiController
currently documents an update operation with response:
HttpResponse::HTTP_CREATED (201); change that OA\Response to use
HttpResponse::HTTP_OK (200) or HttpResponse::HTTP_NO_CONTENT (204) instead and
update the controller method that performs the user group assignment (the method
containing this OA\Response) so the actual HTTP response status it returns
matches the new code.
- Around line 397-402: The OpenAPI annotation in OAuth2UserApiController is
incorrectly using HttpResponse::HTTP_CREATED for a PUT update response; update
the OA\Response entry in the controller's update annotation to use
HttpResponse::HTTP_OK (200) so the documented status matches the update
semantics and returned User payload in the OA\JsonContent.
- Around line 450-455: The OpenAPI response annotation in
OAuth2UserApiController uses HttpResponse::HTTP_CREATED for an update endpoint;
change the response status to HttpResponse::HTTP_OK (200) to match an update
operation. Locate the OA\Response entry in the controller annotation (the block
that currently has response: HttpResponse::HTTP_CREATED and description
'Updated') and replace HttpResponse::HTTP_CREATED with HttpResponse::HTTP_OK
and, if desired, update the description to 'OK' or keep 'Updated' for clarity.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: d9a428ab-13a3-4653-a1b3-9b59842b0f6b

📥 Commits

Reviewing files that changed from the base of the PR and between 446696c and 1a0c2b0.

📒 Files selected for processing (9)
  • app/Http/Controllers/Api/OAuth2/OAuth2UserApiController.php
  • app/Swagger/Models/UserInfoResponseSchema.php
  • app/Swagger/OAuth2UserApiControllerSchemas.php
  • app/Swagger/Requests/CreateUserRequestSchema.php
  • app/Swagger/Requests/UpdateUserGroupsRequestSchema.php
  • app/Swagger/Requests/UpdateUserPicRequestSchema.php
  • app/Swagger/Requests/UpdateUserRequestSchema.php
  • app/Swagger/Requests/UserFieldsSchema.php
  • app/Swagger/Security/UsersOAuth2Schema.php

Comment on lines +397 to +402
responses: [
new OA\Response(
response: HttpResponse::HTTP_CREATED,
description: 'Updated',
content: new OA\JsonContent(ref: '#/components/schemas/User')
),
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Incorrect HTTP status code for update operation.

The OpenAPI annotation documents HTTP_CREATED (201) for a PUT update operation. Per REST semantics, updates should return HTTP_OK (200) when returning the updated resource.

Suggested fix
         responses: [
             new OA\Response(
-                response: HttpResponse::HTTP_CREATED,
+                response: HttpResponse::HTTP_OK,
                 description: 'Updated',
                 content: new OA\JsonContent(ref: '#/components/schemas/User')
             ),
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
responses: [
new OA\Response(
response: HttpResponse::HTTP_CREATED,
description: 'Updated',
content: new OA\JsonContent(ref: '#/components/schemas/User')
),
responses: [
new OA\Response(
response: HttpResponse::HTTP_OK,
description: 'Updated',
content: new OA\JsonContent(ref: '#/components/schemas/User')
),
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@app/Http/Controllers/Api/OAuth2/OAuth2UserApiController.php` around lines 397
- 402, The OpenAPI annotation in OAuth2UserApiController is incorrectly using
HttpResponse::HTTP_CREATED for a PUT update response; update the OA\Response
entry in the controller's update annotation to use HttpResponse::HTTP_OK (200)
so the documented status matches the update semantics and returned User payload
in the OA\JsonContent.

Comment on lines +450 to +455
),
responses: [
new OA\Response(
response: HttpResponse::HTTP_CREATED,
description: 'Updated',
content: new OA\JsonContent(ref: '#/components/schemas/User')
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Incorrect HTTP status code for update operation.

Same issue as updateMe - should use HTTP_OK (200) instead of HTTP_CREATED (201) for the update response.

Suggested fix
         responses: [
             new OA\Response(
-                response: HttpResponse::HTTP_CREATED,
+                response: HttpResponse::HTTP_OK,
                 description: 'Updated',
                 content: new OA\JsonContent(ref: '#/components/schemas/User')
             ),
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
),
responses: [
new OA\Response(
response: HttpResponse::HTTP_CREATED,
description: 'Updated',
content: new OA\JsonContent(ref: '#/components/schemas/User')
),
responses: [
new OA\Response(
response: HttpResponse::HTTP_OK,
description: 'Updated',
content: new OA\JsonContent(ref: '#/components/schemas/User')
),
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@app/Http/Controllers/Api/OAuth2/OAuth2UserApiController.php` around lines 450
- 455, The OpenAPI response annotation in OAuth2UserApiController uses
HttpResponse::HTTP_CREATED for an update endpoint; change the response status to
HttpResponse::HTTP_OK (200) to match an update operation. Locate the OA\Response
entry in the controller annotation (the block that currently has response:
HttpResponse::HTTP_CREATED and description 'Updated') and replace
HttpResponse::HTTP_CREATED with HttpResponse::HTTP_OK and, if desired, update
the description to 'OK' or keep 'Updated' for clarity.

Comment on lines +499 to +504
responses: [
new OA\Response(
response: HttpResponse::HTTP_CREATED,
description: 'Updated',
content: new OA\JsonContent(ref: '#/components/schemas/User')
),
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Incorrect HTTP status code for update operation.

Same issue - should use HTTP_OK (200) instead of HTTP_CREATED (201) for updating the profile picture.

Suggested fix
         responses: [
             new OA\Response(
-                response: HttpResponse::HTTP_CREATED,
+                response: HttpResponse::HTTP_OK,
                 description: 'Updated',
                 content: new OA\JsonContent(ref: '#/components/schemas/User')
             ),
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@app/Http/Controllers/Api/OAuth2/OAuth2UserApiController.php` around lines 499
- 504, The OpenAPI response for the update operation in OAuth2UserApiController
currently uses HttpResponse::HTTP_CREATED (201); change it to
HttpResponse::HTTP_OK (200) so the OA\Response for the update (the block
creating new OA\Response in OAuth2UserApiController, around the
profile-picture/update endpoint) correctly reflects an update operation
returning 200 instead of 201.

Comment on lines +801 to +805
responses: [
new OA\Response(
response: HttpResponse::HTTP_CREATED,
description: 'Updated'
),
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Incorrect HTTP status code for update operation.

Same issue - should use HTTP_OK (200) or HTTP_NO_CONTENT (204) instead of HTTP_CREATED (201) for updating user group assignments.

Suggested fix
         responses: [
             new OA\Response(
-                response: HttpResponse::HTTP_CREATED,
+                response: HttpResponse::HTTP_OK,
                 description: 'Updated'
             ),
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
responses: [
new OA\Response(
response: HttpResponse::HTTP_CREATED,
description: 'Updated'
),
responses: [
new OA\Response(
response: HttpResponse::HTTP_OK,
description: 'Updated'
),
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@app/Http/Controllers/Api/OAuth2/OAuth2UserApiController.php` around lines 801
- 805, The OpenAPI annotation in OAuth2UserApiController currently documents an
update operation with response: HttpResponse::HTTP_CREATED (201); change that
OA\Response to use HttpResponse::HTTP_OK (200) or HttpResponse::HTTP_NO_CONTENT
(204) instead and update the controller method that performs the user group
assignment (the method containing this OA\Response) so the actual HTTP response
status it returns matches the new code.

*/
#[OA\Put(
path: '/api/v1/users/{id}/groups',
summary: 'Update user group assignments (only for account type "SERVICE")',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@matiasperrone-exo please remove this and follow the pattern from this PR for service accountshttps://github.com/OpenStackweb/openstackid/commit/446696cead8b4bfa2aa389d039e5aa7fc25469e1#diff-ea26379160b49edfe9456c46a5b96b7258fa1d1192e91ba66d1dd44ebd99f8deR354

content: new OA\JsonContent(ref: '#/components/schemas/UpdateUserGroupsRequest')
),
responses: [
new OA\Response(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

@smarcet smarcet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@matiasperrone-exo please review comments and rebase with main to get the proper preview for the swagger doc many thanks

security: [
[
'user_oauth2' => [
IUserScopes::Profile,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@matiasperrone-exo
Scope semantics : AND vs OR

In OpenAPI, this means all three scopes are required simultaneously. In practice, the UserInfo endpoint returns different claims based on which individual scopes the token has (per the OIDC
spec). If any single scope is sufficient to access the endpoint, the correct representation is:
security: [
['user_oauth2' => [IUserScopes::Profile]],
['user_oauth2' => [IUserScopes::Email]],
['user_oauth2' => [IUserScopes::Address]],
]
This tells Swagger UI "any one of these scopes grants access." Verify against the actual ApiEndpoint database configuration for what's enforced at runtime.

security: [
[
'user_oauth2' => [
IUserScopes::Profile,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants