Skip to content

Commit 6ca28a1

Browse files
committed
Add @api public tags to JSONRPC classes and errors
Enabled YARD lint enforcement for @api tags and added @api public annotations to all major JSONRPC classes, helpers, and error types. This clarifies public API surfaces for documentation and tooling.
1 parent 2d54f4f commit 6ca28a1

10 files changed

Lines changed: 23 additions & 1 deletion

.yard-lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ Tags/TagTypePosition:
151151

152152
Tags/ApiTags:
153153
Description: 'Enforces @api tags on public objects.'
154-
Enabled: false # Opt-in validator
154+
Enabled: true # Opt-in validator
155155
Severity: error
156156
AllowedApis:
157157
- public

lib/jsonrpc/batch_request.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ module JSONRPC
66
# A batch request is an Array filled with Request objects to send several requests at once.
77
# The Server should respond with an Array containing the corresponding Response objects.
88
#
9+
# @api public
10+
#
911
# @example Create a batch request with multiple requests
1012
# batch = JSONRPC::BatchRequest.new([
1113
# JSONRPC::Request.new(method: "sum", params: [1, 2, 4], id: "1"),

lib/jsonrpc/batch_response.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ module JSONRPC
77
# a Batch Request. The Server should respond with one Response for each Request
88
# (except for Notifications which don't receive responses).
99
#
10+
# @api public
11+
#
1012
# @example Create a batch response
1113
# batch = JSONRPC::BatchResponse.new([
1214
# JSONRPC::Response.new(result: 7, id: "1"),

lib/jsonrpc/errors/internal_error.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ module JSONRPC
55
#
66
# Raised when there was an internal JSON-RPC error.
77
#
8+
# @api public
9+
#
810
# @example Create an internal error
911
# error = JSONRPC::Errors::InternalError.new(data: { details: 'Unexpected server error' })
1012
#

lib/jsonrpc/errors/invalid_params_error.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ module JSONRPC
55
#
66
# Raised when invalid method parameter(s) were provided.
77
#
8+
# @api public
9+
#
810
# @example Create an invalid params error
911
# error = JSONRPC::InvalidParamsError.new(data: { details: "Expected array of integers" })
1012
#

lib/jsonrpc/errors/invalid_request_error.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ module JSONRPC
55
#
66
# Raised when the JSON sent is not a valid Request object.
77
#
8+
# @api public
9+
#
810
# @example Create an invalid request error
911
# error = JSONRPC::InvalidRequestError.new(data: { details: "Method must be a string" })
1012
#

lib/jsonrpc/errors/method_not_found_error.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ module JSONRPC
55
#
66
# Raised when the method does not exist / is not available.
77
#
8+
# @api public
9+
#
810
# @example Create a method not found error
911
# error = JSONRPC::MethodNotFound.new(data: { requested_method: "unknown_method" })
1012
#

lib/jsonrpc/errors/parse_error.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ module JSONRPC
66
# Raised when invalid JSON was received by the server.
77
# An error occurred on the server while parsing the JSON text.
88
#
9+
# @api public
10+
#
911
# @example Create a parse error
1012
# error = JSONRPC::ParseError.new(data: { details: "Unexpected end of input" })
1113
#

lib/jsonrpc/helpers.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
module JSONRPC
44
# Framework-agnostic helpers for JSON-RPC
5+
#
6+
# @api public
7+
#
58
module Helpers
69
# Extends the including class with ClassMethods when module is included
710
#
@@ -21,6 +24,9 @@ def self.included(base)
2124
end
2225

2326
# Class methods for registering JSON-RPC procedure handlers
27+
#
28+
# @api public
29+
#
2430
module ClassMethods
2531
# Registers a JSON-RPC procedure with the given method name
2632
#

lib/jsonrpc/parser.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ module JSONRPC
66
# The Parser handles converting raw JSON strings into appropriate JSONRPC objects
77
# based on the JSON-RPC 2.0 protocol specification.
88
#
9+
# @api public
10+
#
911
# @example Parse a request
1012
# parser = JSONRPC::Parser.new
1113
# request = parser.parse('{"jsonrpc":"2.0","method":"subtract","params":[42,23],"id":1}')

0 commit comments

Comments
 (0)