mortymer 0.0.2 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +19 -20
- data/docs/.vitepress/config.mts +2 -1
- data/docs/guide/introduction.md +6 -6
- data/docs/guide/models.md +2 -2
- data/docs/guide/quick-start.md +4 -10
- data/docs/index.md +1 -1
- data/lib/mortymer/rails.rb +3 -3
- data/lib/mortymer/version.rb +1 -1
- data/mortymer.gemspec +1 -1
- metadata +3 -4
- data/config.ru +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 606d2fd534d7531323c1adee46efd762573215d489f63e21073da23041f8e606
|
4
|
+
data.tar.gz: 00efc44568436fda66af77e8d3b46527e72d95827d8632e2a5c84cde598345a3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cce8ddc9faa57ddebf4c86cd236df5c673927691ff4f84f3b33b61bd96c32d364d2620ad8e5789ed3b737a79d1b59dd105c8b6eff498466b875c47fdc72b505e
|
7
|
+
data.tar.gz: deb03b69691c693b2fdc7226502ad22af06a12d8eeb291c35bcfb08ad12594a36e215b9f459ddcf80de54c9a5ec51b868486976b925040184d90ea6696026596
|
data/README.md
CHANGED
@@ -1,15 +1,14 @@
|
|
1
|
-
#
|
1
|
+
# Mortymer
|
2
2
|
|
3
3
|
```markdown
|
4
|
-
███╗ ███╗ ██████╗ ██████╗ ████████╗██╗
|
5
|
-
████╗ ████║██╔═══██╗██╔══██╗╚══██╔══╝╚██╗
|
6
|
-
██╔████╔██║██║ ██║██████╔╝ ██║ ╚████╔╝
|
7
|
-
██║╚██╔╝██║██║ ██║██╔══██╗ ██║ ╚██╔╝
|
8
|
-
██║ ╚═╝ ██║╚██████╔╝██║ ██║ ██║ ██║
|
9
|
-
╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝
|
4
|
+
███╗ ███╗ ██████╗ ██████╗ ████████╗██╗ ██╗███╗ ███╗███████╗██████╗
|
5
|
+
████╗ ████║██╔═══██╗██╔══██╗╚══██╔══╝╚██╗ ██╔╝████╗ ████║██╔════╝██╔══██╗
|
6
|
+
██╔████╔██║██║ ██║██████╔╝ ██║ ╚████╔╝ ██╔████╔██║█████╗ ██████╔╝
|
7
|
+
██║╚██╔╝██║██║ ██║██╔══██╗ ██║ ╚██╔╝ ██║╚██╔╝██║██╔══╝ ██╔══██╗
|
8
|
+
██║ ╚═╝ ██║╚██████╔╝██║ ██║ ██║ ██║ ██║ ╚═╝ ██║███████╗██║ ██║
|
10
9
|
```
|
11
10
|
|
12
|
-
|
11
|
+
Mortymer is a Ruby gem that simplifies API endpoint management and documentation for Ruby on Rails applications. It provides a clean DSL for defining API endpoints with input/output contracts and automatically generates OpenAPI documentation.
|
13
12
|
|
14
13
|
[](https://badge.fury.io/rb/morty)
|
15
14
|
[](https://opensource.org/licenses/MIT)
|
@@ -27,7 +26,7 @@ Morty is a Ruby gem that simplifies API endpoint management and documentation fo
|
|
27
26
|
Add this line to your application's Gemfile:
|
28
27
|
|
29
28
|
```ruby
|
30
|
-
gem '
|
29
|
+
gem 'mortymer'
|
31
30
|
```
|
32
31
|
|
33
32
|
And then execute:
|
@@ -42,7 +41,7 @@ bundle install
|
|
42
41
|
|
43
42
|
```ruby
|
44
43
|
class UserProfileEndpoint < ApplicationController
|
45
|
-
include
|
44
|
+
include Mortymer::ApiMetadata
|
46
45
|
|
47
46
|
# Define an endpoint with input/output contracts
|
48
47
|
get input: UserProfileInput, output: UserProfileOutput, path: '/api/v1/users/:id/profile'
|
@@ -60,12 +59,12 @@ end
|
|
60
59
|
### Input/Output Contracts
|
61
60
|
|
62
61
|
```ruby
|
63
|
-
class UserProfileInput <
|
62
|
+
class UserProfileInput < Mortymer::Model
|
64
63
|
attribute :id, Types::Integer
|
65
64
|
attribute :include_details, Types::Bool.optional.default(false)
|
66
65
|
end
|
67
66
|
|
68
|
-
class UserProfileOutput <
|
67
|
+
class UserProfileOutput < Mortymer::Model
|
69
68
|
attribute :id, Types::Integer
|
70
69
|
attribute :name, Types::String
|
71
70
|
attribute :email, Types::String
|
@@ -76,7 +75,7 @@ end
|
|
76
75
|
|
77
76
|
```ruby
|
78
77
|
class UserService
|
79
|
-
include
|
78
|
+
include Mortymer::DependenciesDsl
|
80
79
|
|
81
80
|
# Inject dependencies
|
82
81
|
inject UserRepository
|
@@ -95,13 +94,13 @@ In your `config/routes.rb`:
|
|
95
94
|
|
96
95
|
```ruby
|
97
96
|
Rails.application.routes.draw do
|
98
|
-
|
97
|
+
Mortymer::Rails::Routes.new(self).mount_controllers
|
99
98
|
end
|
100
99
|
```
|
101
100
|
|
102
101
|
## OpenAPI Documentation
|
103
102
|
|
104
|
-
|
103
|
+
Mortymer automatically generates OpenAPI documentation for your API endpoints. The documentation includes:
|
105
104
|
|
106
105
|
- Endpoint paths and HTTP methods
|
107
106
|
- Request/response schemas
|
@@ -111,7 +110,7 @@ Morty automatically generates OpenAPI documentation for your API endpoints. The
|
|
111
110
|
To generate the OpenAPI documentation:
|
112
111
|
|
113
112
|
```ruby
|
114
|
-
generator =
|
113
|
+
generator = Mortymer::OpenapiGenerator.new(
|
115
114
|
prefix: "/api",
|
116
115
|
title: "My API",
|
117
116
|
version: "v1"
|
@@ -121,7 +120,7 @@ generator.generate
|
|
121
120
|
|
122
121
|
## Contributing
|
123
122
|
|
124
|
-
We love your input! We want to make contributing to
|
123
|
+
We love your input! We want to make contributing to Mortymer as easy and transparent as possible, whether it's:
|
125
124
|
|
126
125
|
- Reporting a bug
|
127
126
|
- Discussing the current state of the code
|
@@ -155,13 +154,13 @@ This project follows the [Contributor Covenant](https://www.contributor-covenant
|
|
155
154
|
|
156
155
|
## Support
|
157
156
|
|
158
|
-
If you have any questions or need help with
|
157
|
+
If you have any questions or need help with Mortymer:
|
159
158
|
|
160
|
-
- Open an [issue](https://github.com/yourusername/
|
159
|
+
- Open an [issue](https://github.com/yourusername/mortymer/issues)
|
161
160
|
- Join our [Discord community](#) (coming soon)
|
162
161
|
|
163
162
|
## Credits
|
164
163
|
|
165
|
-
|
164
|
+
Mortymer is maintained by [Adrian Gonzalez] and was inspired by the need for a simple,
|
166
165
|
yet powerful API management solution in the Ruby ecosystem, that integrates well
|
167
166
|
with existing frameworks. We deserve a FastAPI experience within the ruby side.
|
data/docs/.vitepress/config.mts
CHANGED
@@ -2,7 +2,8 @@ import { defineConfig } from "vitepress";
|
|
2
2
|
|
3
3
|
// https://vitepress.dev/reference/site-config
|
4
4
|
export default defineConfig({
|
5
|
-
|
5
|
+
base: "/morty/",
|
6
|
+
title: "Mortymer",
|
6
7
|
description:
|
7
8
|
"Standalone API definition for ruby frameworks based on dry.rb. Rails compatible from day 0 with a full Ruby flavored dependency injection engine.",
|
8
9
|
markdown: {
|
data/docs/guide/introduction.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Introduction
|
2
2
|
|
3
|
-
|
3
|
+
Mortymer is a modern Ruby gem designed to enhance API development with features
|
4
4
|
present in most modern API-first frameworks, like FastAPI and bringing some goodies
|
5
5
|
to the ruby ecosystem. It brings type safety, automatic documentation,
|
6
6
|
and dependency injection to your APIs, while beign web framework agnostic and
|
@@ -15,17 +15,17 @@ other frameworks like Sinatra or Grape.
|
|
15
15
|
- **DI**: Dependency injection and clear separation of concerns through a simple DI Engine.
|
16
16
|
- **Rails Integration**: Seamless integration with Ruby on Rails
|
17
17
|
|
18
|
-
## Why
|
18
|
+
## Why Mortymer?
|
19
19
|
|
20
|
-
|
20
|
+
Mortymer brings the best practices of modern API development to the Ruby ecosystem. Topics
|
21
21
|
like API documentation is really painful, at least from my experience, in the Ruby world. There
|
22
22
|
are a lot of alternatives, from general ones like Rswag to Grape's approach, but none of them
|
23
23
|
feels intuitive or comfortable to use for me. In Rails' I personally hate the strong parameters
|
24
24
|
features, I strongly believe that if you are able to define the shape of your enpoint, i.e, your contract,
|
25
25
|
you should be able to use a fully Parsed object from your params, much like FastAPI's approach.
|
26
|
-
Im tire of beign jelous of FastAPI and want to use Ruby in a similar way, that's when
|
26
|
+
Im tire of beign jelous of FastAPI and want to use Ruby in a similar way, that's when Mortymer was born.
|
27
27
|
|
28
|
-
The name
|
29
|
-
faithful companion. And that is what this gem aims to be, not a replacement for any existent framework,
|
28
|
+
The name Mortymer comes from the popular series Rick and Morty, where Morty is like an assistant, a
|
29
|
+
faithful companion (Mortymer itself is the pet of a heroe of Dota2). And that is what this gem aims to be, not a replacement for any existent framework,
|
30
30
|
but a companion that allows the real heroes (Rails, Sinatra, Grape, etc) shine with their cool features,
|
31
31
|
and not get bored with the API handling stuff.
|
data/docs/guide/models.md
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
# Models
|
2
2
|
|
3
|
-
|
3
|
+
Mortymer models provide a type-safe way to define your API's data structures.
|
4
4
|
They're used for both input validation and output serialization.
|
5
5
|
|
6
6
|
## Basic Model
|
7
7
|
|
8
8
|
```ruby
|
9
|
-
class UserModel <
|
9
|
+
class UserModel < Mortymer::Model
|
10
10
|
attribute :id, Types::Integer
|
11
11
|
attribute :name, Types::String
|
12
12
|
attribute :email, Types::String
|
data/docs/guide/quick-start.md
CHANGED
@@ -18,7 +18,7 @@ cd my_api
|
|
18
18
|
Add Mortymer to your Gemfile:
|
19
19
|
|
20
20
|
```ruby
|
21
|
-
gem '
|
21
|
+
gem 'mortymer'
|
22
22
|
```
|
23
23
|
|
24
24
|
Then install it:
|
@@ -112,6 +112,9 @@ Set up your API controller with Mortymer's features:
|
|
112
112
|
# app/controllers/api/books_controller.rb
|
113
113
|
module Api
|
114
114
|
class BooksController < ApplicationController
|
115
|
+
include Mortymer::DependeciesDsl
|
116
|
+
include Mortymer::ApiMetadata
|
117
|
+
|
115
118
|
inject BookService, as: :books
|
116
119
|
|
117
120
|
class Empty < Mortymer::Model
|
@@ -179,12 +182,3 @@ This simple example showcases several of Mortymer's powerful features:
|
|
179
182
|
- ✨ **Type System**: Strong typing with `Mortymer::Models` which are powered by `Dry::Struct`
|
180
183
|
- 🔌 **Dependency Injection**: Clean service injection with `inject :book_service`
|
181
184
|
- ✅ **Parameter Validation**: Built-in request validation in controllers
|
182
|
-
|
183
|
-
## Next Steps
|
184
|
-
|
185
|
-
Now that you have a basic understanding of Mortymer, you might want to explore:
|
186
|
-
|
187
|
-
- [Type System](./type-system.md) - Learn more about Mortymer's type system
|
188
|
-
- [Dependency Injection](./dependency-injection.md) - Deep dive into DI patterns
|
189
|
-
- [Controllers](./controllers.md) - Advanced controller features
|
190
|
-
- [API Metadata](./api-metadata.md) - API documentation capabilities
|
data/docs/index.md
CHANGED
data/lib/mortymer/rails.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "
|
4
|
-
require "
|
5
|
-
require "
|
3
|
+
require "mortymer/rails/configuration"
|
4
|
+
require "mortymer/rails/endpoint_wrapper_controller"
|
5
|
+
require "mortymer/rails/routes"
|
6
6
|
|
7
7
|
module Mortymer
|
8
8
|
module Rails
|
data/lib/mortymer/version.rb
CHANGED
data/mortymer.gemspec
CHANGED
@@ -16,7 +16,7 @@ Gem::Specification.new do |spec|
|
|
16
16
|
|
17
17
|
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
18
18
|
|
19
|
-
spec.metadata["homepage_uri"] =
|
19
|
+
spec.metadata["homepage_uri"] = "https://adriangs1996.github.io/morty/"
|
20
20
|
spec.metadata["source_code_uri"] = spec.homepage
|
21
21
|
spec.metadata["changelog_uri"] = "#{spec.homepage}/CHANGELOG.md"
|
22
22
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mortymer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adrian Gonzalez
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-03-
|
11
|
+
date: 2025-03-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dry-monads
|
@@ -110,7 +110,6 @@ files:
|
|
110
110
|
- LICENSE.txt
|
111
111
|
- README.md
|
112
112
|
- Rakefile
|
113
|
-
- config.ru
|
114
113
|
- docs/.vitepress/config.mts
|
115
114
|
- docs/.vitepress/theme/Layout.vue
|
116
115
|
- docs/.vitepress/theme/index.ts
|
@@ -147,7 +146,7 @@ licenses:
|
|
147
146
|
- MIT
|
148
147
|
metadata:
|
149
148
|
allowed_push_host: https://rubygems.org
|
150
|
-
homepage_uri: https://github.
|
149
|
+
homepage_uri: https://adriangs1996.github.io/morty/
|
151
150
|
source_code_uri: https://github.com/adriangs1996/morty
|
152
151
|
changelog_uri: https://github.com/adriangs1996/morty/CHANGELOG.md
|
153
152
|
post_install_message:
|