Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
d50a5e0
Add api folder and committee api controller
jvitorbarros15 Jan 16, 2026
2b9cead
updated controller, added routes and added a format_committees helper…
usmannsiddiqui Jan 20, 2026
c6fd0cb
Add Render JSON and keys to_s
jvitorbarros15 Jan 20, 2026
215cc48
Api key set in .envrc
usmannsiddiqui Jan 20, 2026
6cbd4ce
Removed some .md docs from version control
usmannsiddiqui Jan 20, 2026
15d9cf1
Merge main
jvitorbarros15 Feb 2, 2026
ccbad19
Replace ENV API key auth with ExternalApp token authentication and ad…
jvitorbarros15 Feb 2, 2026
77caf9a
Rubocop Corrections
jvitorbarros15 Feb 2, 2026
06f70e2
Add committee_role_normalizer and request specs
jvitorbarros15 Feb 3, 2026
2a81bc6
Merge branch 'main' into api-controller
jvitorbarros15 Feb 3, 2026
1e5aa60
Fix Student name with student_fname and student_lname and add interna…
jvitorbarros15 Feb 3, 2026
4dc14fe
Remove normalizer and moved it to FAMS_TOOL
jvitorbarros15 Feb 4, 2026
214bb98
Simplified Routes for API and add basic spec for committee_records_co…
jvitorbarros15 Feb 4, 2026
3e1dce5
Refactor committee formatting to reduce RuboCop complexity
jvitorbarros15 Feb 4, 2026
e3f5d38
Merge branch 'main' into api-controller
jvitorbarros15 Feb 4, 2026
c822da2
Simplified the API controller objects and add join scope methods
jvitorbarros15 Feb 5, 2026
7d949d6
Add more rspec tests for API controller
jvitorbarros15 Feb 9, 2026
481d26b
Merge main
jvitorbarros15 Feb 9, 2026
d608160
Add request specs for committee records response structure
jvitorbarros15 Feb 9, 2026
4718825
Add request spec for multiple committee memberships response
jvitorbarros15 Feb 10, 2026
2e93edf
Add gem rswag
jvitorbarros15 Feb 12, 2026
553e627
Add rswag initial documentation
jvitorbarros15 Feb 12, 2026
8ace73c
Add rswag docs with auth (working)
jvitorbarros15 Feb 19, 2026
2e9f672
Fix rswag spec (All tests passing)
jvitorbarros15 Feb 20, 2026
05943a8
Rubocop corrections
jvitorbarros15 Feb 20, 2026
b40fe34
added a class for fams tools
madhurakhandkar Feb 24, 2026
049a3a5
Add the Rswag documentation back, move gem rswag to global scope, rem…
jvitorbarros15 Feb 24, 2026
f764690
Merge branch 'api-controller' of https://github.com/psu-libraries/etd…
madhurakhandkar Feb 24, 2026
b02b68e
Resolve merge conflict in committee_records_spec.rb, keeping remote c…
madhurakhandkar Feb 24, 2026
f8df7f4
Fix RuboCop Rswag DSL issues, exclude Rswag spec from problematic cop…
jvitorbarros15 Feb 25, 2026
14f3b55
Remove more comments froom api controller
jvitorbarros15 Feb 25, 2026
42d7a5b
Resolve merge conflict in routes.rb and keep admin mounts for Sidekiq…
jvitorbarros15 Feb 25, 2026
5634d04
Merge branch 'api-controller' of https://github.com/psu-libraries/etd…
jvitorbarros15 Feb 25, 2026
42b3050
Remove response 400 using x-api-key from committee_records_spec
jvitorbarros15 Feb 25, 2026
1938712
Switch committee records API auth from Bearer token to X-API-KEY header
usmannsiddiqui Feb 26, 2026
817af32
Rubocop corrections
jvitorbarros15 Feb 27, 2026
ff06adf
Fix committee_records_controller_spec.rb changing the authorization h…
jvitorbarros15 Feb 27, 2026
45d1dbe
Enable swagger_filter to dynamically set host from request
usmannsiddiqui Mar 17, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,4 @@ config/settings/*.local.yml
config/environments/*.local.yml

/config/master.key
docs/development/
13 changes: 13 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -322,3 +322,16 @@ Naming/MemoizedInstanceVariableName:

Style/MultipleComparison:
Enabled: false


# Rubocop doesn't seem to understand the rswag DSL.
# Exclude the rswag spec file spec/requests/api/v1/api_docs/committee_records_spec.rb
# from RSpec/EmptyExampleGroup. Without this, autocorrect will delete
# the code in that file.
RSpec/EmptyExampleGroup:
Exclude:
- 'spec/requests/api/v1/api_docs/committee_records_spec.rb'

RSpec/VariableName:
Exclude:
- 'spec/requests/api/v1/api_docs/committee_records_spec.rb'
5 changes: 4 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ gem 'config', '~> 5.5.2'
gem 'discard'
# Temporary file downloads over HTTP
gem 'down'

# API documentation
gem 'rswag'

group :development, :test do
# Access an IRB console on exception pages or by using <%= console %> anywhere in the code.
Expand All @@ -95,6 +96,8 @@ group :development, :test do
# Coverage report
gem 'simplecov', '~> 0.17.0'
gem 'mutex_m'
# API documentation
gem 'rswag'
Comment on lines +99 to +100
Copy link
Contributor

Choose a reason for hiding this comment

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

This will actually need to be moved up into the global scope. This is why CI is failing, the RSwag engine is used to display the documentation in production, but we don't have it installing in production environments.

end

group :development do
Expand Down
19 changes: 19 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,9 @@ GEM
railties (>= 4.2.0)
thor (>= 0.14, < 2.0)
json (2.16.0)
json-schema (6.1.0)
addressable (~> 2.8)
bigdecimal (>= 3.1, < 5)
jwt (2.10.1)
base64
language_server-protocol (3.17.0.5)
Expand Down Expand Up @@ -402,6 +405,21 @@ GEM
rspec-retry (0.6.2)
rspec-core (> 3.3)
rspec-support (3.13.2)
rswag (2.17.0)
rswag-api (= 2.17.0)
rswag-specs (= 2.17.0)
rswag-ui (= 2.17.0)
rswag-api (2.17.0)
activesupport (>= 5.2, < 8.2)
railties (>= 5.2, < 8.2)
rswag-specs (2.17.0)
activesupport (>= 5.2, < 8.2)
json-schema (>= 2.2, < 7.0)
railties (>= 5.2, < 8.2)
rspec-core (>= 2.14)
rswag-ui (2.17.0)
actionpack (>= 5.2, < 8.2)
railties (>= 5.2, < 8.2)
rubocop (1.81.7)
json (~> 2.3)
language_server-protocol (~> 3.17.0.2)
Expand Down Expand Up @@ -599,6 +617,7 @@ DEPENDENCIES
rsolr (~> 2.5.0)
rspec-rails (~> 7.0.0)
rspec-retry (~> 0.6.0)
rswag
sassc-rails (~> 2.1.2)
seedbank (~> 0.5.0)
selenium-webdriver (~> 4.26)
Expand Down
80 changes: 80 additions & 0 deletions app/controllers/api/v1/committee_records_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
module Api
module V1
class CommitteeRecordsController < ApplicationController
skip_before_action :verify_authenticity_token

before_action :authenticate_api_key

def faculty_committees
access_id = params[:access_id]
if access_id.blank?
render json: { error: 'access_id is required' }, status: :bad_request
return
end

committee_memberships = CommitteeMember
.joins(:submission).where('submissions.status LIKE "released for publication%" OR submissions.status = "waiting for publication release"')
.includes(:committee_role, submission: [:author, :degree, :program])
.where(access_id: access_id)

render json: {
faculty_access_id: access_id,
committees: format_committees(committee_memberships)
}, status: :ok
rescue StandardError => e
render json: { error: e.message }, status: :internal_server_error
end

private

def authenticate_api_key
token = request.headers['HTTP_X_API_KEY']

@api_token = ApiToken.includes(:external_app).find_by(token: token)
return unauthorized! unless @api_token

@external_app = @api_token.external_app
@api_token.update_column(:last_used_at, Time.current)

true
end

def unauthorized!
render json: { error: "Unauthorized" }, status: :unauthorized
end

def format_committees(committee_memberships)
committee_memberships.map { |membership| committee_payload(membership) }
end

def committee_payload(membership)
submission = membership.submission
author = submission&.author

{
committee_member_id: membership.id,

role: membership.committee_role&.name,
role_code: membership.committee_role&.code,

student_fname: author&.first_name,
student_lname: author&.last_name,
student_access_id: author&.access_id,

submission_id: submission.id,
title: submission.title,
degree_name: submission.degree&.name,
program_name: submission.program&.name,
semester: submission.semester,
year: submission.year,

approval_started_at: membership.approval_started_at,
final_submission_approved_at: submission.final_submission_approved_at,

submission_status: submission.status,
committee_member_status: membership.status
}
end
end
end
end
14 changes: 14 additions & 0 deletions app/models/external_app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,24 @@ def self.build
end
end

class FamsTools
NAME = "FAMS Tools"

def self.build
ExternalApp.find_or_create_by(name: NAME) do |app|
app.api_tokens.build
end
end
end

def self.etda_explore
EtdaExplore.build
end

def self.fams_tools
FamsTools.build
end

def token
api_tokens.first.token
end
Expand Down
14 changes: 14 additions & 0 deletions config/initializers/rswag_api.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Rswag::Api.configure do |c|

# Specify a root folder where Swagger JSON files are located
# This is used by the Swagger middleware to serve requests for API descriptions
# NOTE: If you're using rswag-specs to generate Swagger, you'll need to ensure
# that it's configured to generate files in the same folder
c.openapi_root = Rails.root.to_s + '/swagger'

# Inject a lambda function to alter the returned Swagger prior to serialization
# The function will have access to the rack env for the current request
# For example, you could leverage this to dynamically assign the "host" property
#
c.swagger_filter = lambda { |swagger, env| swagger['host'] = env['HTTP_HOST'] }
end
16 changes: 16 additions & 0 deletions config/initializers/rswag_ui.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Rswag::Ui.configure do |c|

# List the Swagger endpoints that you want to be documented through the
# swagger-ui. The first parameter is the path (absolute or relative to the UI
# host) to the corresponding endpoint and the second is a title that will be
# displayed in the document selector.
# NOTE: If you're using rspec-api to expose Swagger files
# (under openapi_root) as JSON or YAML endpoints, then the list below should
# correspond to the relative paths for those endpoints.

c.swagger_endpoint '/admin/api-docs/v1/swagger.yaml', 'API V1 Docs'

# Add Basic Auth in case your API is private
# c.basic_auth_enabled = true
# c.basic_auth_credentials 'username', 'password'
end
9 changes: 8 additions & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
require 'sidekiq/web'

Rails.application.routes.draw do

devise_for :approvers, path: 'approver'
devise_for :authors, path: 'author'
devise_for :admins, path: 'admin'
Expand All @@ -20,6 +19,12 @@

mount OkComputer::Engine, at: "/healthcheck"

namespace :api do
namespace :v1 do
post "committee_records/faculty_committees"
end
end

## works: get '/committee_members/autocomplete', to: 'ldap_lookup#autocomplete', as: :committee_members_autocomplete
get '/committee_members/autocomplete', to: 'application#autocomplete', as: :committee_members_autocomplete

Expand All @@ -43,6 +48,8 @@

authenticate :admin do
mount Sidekiq::Web => '/sidekiq'
mount Rswag::Api::Engine => '/api-docs'
mount Rswag::Ui::Engine => '/api-docs'
end

get '/custom_report', to: 'reports#custom_report_index', as: :custom_report_index
Expand Down
8 changes: 4 additions & 4 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@
t.index ["name"], name: "index_degrees_on_name", unique: true
end

create_table "external_apps", charset: "utf8mb4", collation: "utf8mb4_unicode_ci", force: :cascade do |t|
create_table "external_apps", charset: "utf8mb4", force: :cascade do |t|
t.string "name"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
Expand Down Expand Up @@ -277,7 +277,7 @@
t.index ["name", "code"], name: "index_programs_on_name_and_code", unique: true
end

create_table "remediated_final_submission_files", charset: "utf8mb4", collation: "utf8mb4_unicode_ci", force: :cascade do |t|
create_table "remediated_final_submission_files", charset: "utf8mb4", force: :cascade do |t|
t.bigint "submission_id", null: false
t.bigint "final_submission_file_id", null: false
t.text "asset"
Expand Down Expand Up @@ -342,9 +342,9 @@
t.string "lionpath_semester"
t.string "academic_program"
t.string "degree_checkout_status"
t.datetime "author_release_warning_sent_at", precision: nil
t.datetime "acknowledgment_page_submitted_at", precision: nil
t.string "candidate_number"
t.datetime "acknowledgment_page_submitted_at", precision: nil
t.datetime "author_release_warning_sent_at", precision: nil
t.string "extension_token"
t.datetime "last_lionpath_export_at", precision: nil
t.index ["author_id"], name: "submissions_author_id_fk"
Expand Down
Loading