Skip to content

Conversation

@opencode-agent
Copy link
Contributor

I've addressed the issue where namespaced model and resource classes were causing crashes in the jsonapi-swagger generator.

Key changes include:

  • Fixed model_klass in SwaggerGenerator to use the full model_class_name instead of just the file_name, ensuring namespaced models are correctly constantized.
  • Refactored Jsonapi::Swagger::Resource.with to use safe_constantize instead of Object.const_defined?, which improves compatibility with Rails' Zeitwerk/autoloading for namespaced constants.
  • Added improved support for namespaced serializable resource classes (e.g., Dental::SerializablePatient for a Dental::Patient model).
  • Corrected common misspellings (resouces -> resources) throughout the generator and templates for better code quality and consistency.

These changes ensure that running rails generate jsonapi:swagger MyModule::MyModel works correctly as expected.

Closes #14

New%20session%20-%202026-01-25T08%3A36%3A59.927Z
opencode session  |  github run

Co-authored-by: superiorlu <superiorlu@users.noreply.github.com>
@superiorlu superiorlu merged commit 55a2b67 into master Jan 25, 2026
1 check failed
@superiorlu superiorlu deleted the opencode/issue14-20260125083700 branch January 25, 2026 09:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support for model and resource classes in module

1 participant