scalar_api_ruby 0.2.0 → 0.3.0

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.
Files changed (160) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +71 -0
  3. data/README.md +5 -3
  4. data/SKILL.md +3 -1
  5. data/api.md +20 -181
  6. data/lib/scalar_api_ruby/client.rb +14 -5
  7. data/lib/scalar_api_ruby/errors.rb +22 -0
  8. data/lib/scalar_api_ruby/file_part.rb +13 -1
  9. data/lib/scalar_api_ruby/internal/transport/base_client.rb +187 -42
  10. data/lib/scalar_api_ruby/internal/transport/connection_pool.rb +160 -0
  11. data/lib/scalar_api_ruby/internal/transport/pooled_net_requester.rb +77 -10
  12. data/lib/scalar_api_ruby/internal/type/base_model.rb +70 -18
  13. data/lib/scalar_api_ruby/internal/type/boolean.rb +3 -1
  14. data/lib/scalar_api_ruby/internal/type/converter.rb +13 -3
  15. data/lib/scalar_api_ruby/internal/type/enum.rb +9 -4
  16. data/lib/scalar_api_ruby/internal/type/file_input.rb +8 -2
  17. data/lib/scalar_api_ruby/internal/type/hash_of.rb +3 -1
  18. data/lib/scalar_api_ruby/internal/type/union.rb +21 -7
  19. data/lib/scalar_api_ruby/internal/type/unknown.rb +3 -1
  20. data/lib/scalar_api_ruby/internal/util.rb +277 -17
  21. data/lib/scalar_api_ruby/internal.rb +5 -1
  22. data/lib/scalar_api_ruby/models/access_group_create_params.rb +3 -3
  23. data/lib/scalar_api_ruby/models/access_group_create_response.rb +6 -6
  24. data/lib/scalar_api_ruby/models/access_group_retrieve_response.rb +6 -6
  25. data/lib/scalar_api_ruby/models/api_document.rb +3 -3
  26. data/lib/scalar_api_ruby/models/docs_project.rb +3 -3
  27. data/lib/scalar_api_ruby/models/github_project.rb +16 -4
  28. data/lib/scalar_api_ruby/models/mcp/mcp_server.rb +23 -18
  29. data/lib/scalar_api_ruby/models/mcp/server_create_response.rb +1 -7
  30. data/lib/scalar_api_ruby/models/mcp/server_list_response.rb +72 -1
  31. data/lib/scalar_api_ruby/models/sdk.rb +13 -7
  32. data/lib/scalar_api_ruby/models/sdk_build_params.rb +7 -1
  33. data/lib/scalar_api_ruby/models/sdk_create_params.rb +14 -7
  34. data/lib/scalar_api_ruby/models/sdk_update_params.rb +13 -3
  35. data/lib/scalar_api_ruby/models/sdk_version.rb +5 -34
  36. data/lib/scalar_api_ruby/models/sdks/repository_link_params.rb +33 -2
  37. data/lib/scalar_api_ruby/models/sdks/repository_update_publishing_params.rb +31 -1
  38. data/lib/scalar_api_ruby/models/sdks/version_create_params.rb +13 -7
  39. data/lib/scalar_api_ruby/models.rb +28 -31
  40. data/lib/scalar_api_ruby/request_options.rb +13 -5
  41. data/lib/scalar_api_ruby/resources/access_groups.rb +1 -1
  42. data/lib/scalar_api_ruby/resources/mcp/servers.rb +7 -74
  43. data/lib/scalar_api_ruby/resources/registry.rb +44 -16
  44. data/lib/scalar_api_ruby/resources/rules.rb +16 -8
  45. data/lib/scalar_api_ruby/resources/schemas/access_group.rb +6 -2
  46. data/lib/scalar_api_ruby/resources/schemas/version.rb +18 -8
  47. data/lib/scalar_api_ruby/resources/schemas.rb +6 -2
  48. data/lib/scalar_api_ruby/resources/sdks/repositories.rb +38 -6
  49. data/lib/scalar_api_ruby/resources/sdks/versions.rb +22 -5
  50. data/lib/scalar_api_ruby/resources/sdks.rb +45 -10
  51. data/lib/scalar_api_ruby/resources/themes.rb +1 -3
  52. data/lib/scalar_api_ruby/version.rb +1 -1
  53. data/lib/scalar_api_ruby.rb +4 -19
  54. data/rbi/scalar_api_ruby/client.rbi +5 -0
  55. data/rbi/scalar_api_ruby/errors.rbi +15 -27
  56. data/rbi/scalar_api_ruby/internal/transport/base_client.rbi +45 -54
  57. data/rbi/scalar_api_ruby/internal/transport/connection_pool.rbi +44 -0
  58. data/rbi/scalar_api_ruby/internal/transport/pooled_net_requester.rbi +14 -14
  59. data/rbi/scalar_api_ruby/internal/type/base_model.rbi +28 -35
  60. data/rbi/scalar_api_ruby/internal/type/converter.rbi +9 -30
  61. data/rbi/scalar_api_ruby/internal/type/enum.rbi +1 -5
  62. data/rbi/scalar_api_ruby/internal/type/request_parameters.rbi +1 -3
  63. data/rbi/scalar_api_ruby/internal/type/union.rbi +2 -9
  64. data/rbi/scalar_api_ruby/internal/util.rbi +101 -112
  65. data/rbi/scalar_api_ruby/internal.rbi +1 -2
  66. data/rbi/scalar_api_ruby/models/access_group_create_params.rbi +4 -4
  67. data/rbi/scalar_api_ruby/models/access_group_create_response.rbi +6 -6
  68. data/rbi/scalar_api_ruby/models/access_group_retrieve_response.rbi +6 -6
  69. data/rbi/scalar_api_ruby/models/api_document.rbi +3 -3
  70. data/rbi/scalar_api_ruby/models/docs_project.rbi +3 -3
  71. data/rbi/scalar_api_ruby/models/github_project.rbi +18 -6
  72. data/rbi/scalar_api_ruby/models/mcp/mcp_server.rbi +22 -16
  73. data/rbi/scalar_api_ruby/models/mcp/server_create_response.rbi +5 -19
  74. data/rbi/scalar_api_ruby/models/mcp/server_list_response.rbi +116 -1
  75. data/rbi/scalar_api_ruby/models/sdk.rbi +15 -9
  76. data/rbi/scalar_api_ruby/models/sdk_build_params.rbi +15 -1
  77. data/rbi/scalar_api_ruby/models/sdk_create_params.rbi +19 -6
  78. data/rbi/scalar_api_ruby/models/sdk_update_params.rbi +9 -4
  79. data/rbi/scalar_api_ruby/models/sdk_version.rbi +7 -52
  80. data/rbi/scalar_api_ruby/models/sdks/repository_link_params.rbi +59 -0
  81. data/rbi/scalar_api_ruby/models/sdks/repository_update_publishing_params.rbi +45 -0
  82. data/rbi/scalar_api_ruby/models/sdks/version_create_params.rbi +16 -6
  83. data/rbi/scalar_api_ruby/request_options.rbi +6 -8
  84. data/rbi/scalar_api_ruby/resources/access_groups.rbi +1 -1
  85. data/rbi/scalar_api_ruby/resources/mcp/servers.rbi +6 -51
  86. data/rbi/scalar_api_ruby/resources/sdks/repositories.rbi +28 -1
  87. data/rbi/scalar_api_ruby/resources/sdks/versions.rbi +21 -4
  88. data/rbi/scalar_api_ruby/resources/sdks.rbi +40 -10
  89. data/sig/scalar_api_ruby/client.rbs +2 -0
  90. data/sig/scalar_api_ruby/errors.rbs +6 -0
  91. data/sig/scalar_api_ruby/internal/transport/base_client.rbs +19 -1
  92. data/sig/scalar_api_ruby/internal/transport/connection_pool.rbs +19 -0
  93. data/sig/scalar_api_ruby/internal/transport/pooled_net_requester.rbs +11 -1
  94. data/sig/scalar_api_ruby/internal/type/base_model.rbs +4 -0
  95. data/sig/scalar_api_ruby/internal/util.rbs +29 -1
  96. data/sig/scalar_api_ruby/models/access_group_create_params.rbs +5 -5
  97. data/sig/scalar_api_ruby/models/access_group_create_response.rbs +8 -8
  98. data/sig/scalar_api_ruby/models/access_group_retrieve_response.rbs +8 -8
  99. data/sig/scalar_api_ruby/models/api_document.rbs +4 -4
  100. data/sig/scalar_api_ruby/models/docs_project.rbs +4 -4
  101. data/sig/scalar_api_ruby/models/github_project.rbs +17 -7
  102. data/sig/scalar_api_ruby/models/mcp/mcp_server.rbs +22 -17
  103. data/sig/scalar_api_ruby/models/mcp/server_create_response.rbs +3 -15
  104. data/sig/scalar_api_ruby/models/mcp/server_list_response.rbs +66 -1
  105. data/sig/scalar_api_ruby/models/sdk.rbs +13 -8
  106. data/sig/scalar_api_ruby/models/sdk_build_params.rbs +7 -0
  107. data/sig/scalar_api_ruby/models/sdk_create_params.rbs +9 -5
  108. data/sig/scalar_api_ruby/models/sdk_update_params.rbs +6 -4
  109. data/sig/scalar_api_ruby/models/sdk_version.rbs +7 -37
  110. data/sig/scalar_api_ruby/models/sdks/repository_link_params.rbs +21 -1
  111. data/sig/scalar_api_ruby/models/sdks/repository_update_publishing_params.rbs +36 -1
  112. data/sig/scalar_api_ruby/models/sdks/version_create_params.rbs +7 -5
  113. data/sig/scalar_api_ruby/resources/access_groups.rbs +1 -1
  114. data/sig/scalar_api_ruby/resources/mcp/servers.rbs +1 -20
  115. data/sig/scalar_api_ruby/resources/sdks/repositories.rbs +6 -0
  116. data/sig/scalar_api_ruby/resources/sdks/versions.rbs +1 -1
  117. data/sig/scalar_api_ruby/resources/sdks.rbs +3 -2
  118. metadata +8 -73
  119. data/lib/scalar_api_ruby/models/mcp/mcp_installation.rb +0 -75
  120. data/lib/scalar_api_ruby/models/mcp/server_delete_params.rb +0 -22
  121. data/lib/scalar_api_ruby/models/mcp/server_retrieve_params.rb +0 -22
  122. data/lib/scalar_api_ruby/models/mcp/server_update_params.rb +0 -52
  123. data/lib/scalar_api_ruby/models/mcp/servers/installation_create_access_group_params.rb +0 -36
  124. data/lib/scalar_api_ruby/models/mcp/servers/installation_create_params.rb +0 -44
  125. data/lib/scalar_api_ruby/models/mcp/servers/installation_delete_access_group_params.rb +0 -36
  126. data/lib/scalar_api_ruby/models/mcp/servers/installation_delete_params.rb +0 -30
  127. data/lib/scalar_api_ruby/models/mcp/servers/installation_list_params.rb +0 -24
  128. data/lib/scalar_api_ruby/models/mcp/servers/installation_list_response.rb +0 -13
  129. data/lib/scalar_api_ruby/models/mcp/servers/installation_retrieve_params.rb +0 -30
  130. data/lib/scalar_api_ruby/models/mcp/servers/installation_update_params.rb +0 -68
  131. data/lib/scalar_api_ruby/models/mcp/servers/mcp_installation_list_item.rb +0 -43
  132. data/lib/scalar_api_ruby/resources/mcp/servers/installations.rb +0 -200
  133. data/rbi/scalar_api_ruby/models/mcp/mcp_installation.rbi +0 -93
  134. data/rbi/scalar_api_ruby/models/mcp/server_delete_params.rbi +0 -37
  135. data/rbi/scalar_api_ruby/models/mcp/server_retrieve_params.rbi +0 -37
  136. data/rbi/scalar_api_ruby/models/mcp/server_update_params.rbi +0 -88
  137. data/rbi/scalar_api_ruby/models/mcp/servers/installation_create_access_group_params.rbi +0 -60
  138. data/rbi/scalar_api_ruby/models/mcp/servers/installation_create_params.rbi +0 -69
  139. data/rbi/scalar_api_ruby/models/mcp/servers/installation_delete_access_group_params.rbi +0 -60
  140. data/rbi/scalar_api_ruby/models/mcp/servers/installation_delete_params.rbi +0 -50
  141. data/rbi/scalar_api_ruby/models/mcp/servers/installation_list_params.rbi +0 -42
  142. data/rbi/scalar_api_ruby/models/mcp/servers/installation_list_response.rbi +0 -17
  143. data/rbi/scalar_api_ruby/models/mcp/servers/installation_retrieve_params.rbi +0 -50
  144. data/rbi/scalar_api_ruby/models/mcp/servers/installation_update_params.rbi +0 -102
  145. data/rbi/scalar_api_ruby/models/mcp/servers/mcp_installation_list_item.rbi +0 -60
  146. data/rbi/scalar_api_ruby/resources/mcp/servers/installations.rbi +0 -140
  147. data/sig/scalar_api_ruby/models/mcp/mcp_installation.rbs +0 -69
  148. data/sig/scalar_api_ruby/models/mcp/server_delete_params.rbs +0 -22
  149. data/sig/scalar_api_ruby/models/mcp/server_retrieve_params.rbs +0 -22
  150. data/sig/scalar_api_ruby/models/mcp/server_update_params.rbs +0 -63
  151. data/sig/scalar_api_ruby/models/mcp/servers/installation_create_access_group_params.rbs +0 -36
  152. data/sig/scalar_api_ruby/models/mcp/servers/installation_create_params.rbs +0 -47
  153. data/sig/scalar_api_ruby/models/mcp/servers/installation_delete_access_group_params.rbs +0 -36
  154. data/sig/scalar_api_ruby/models/mcp/servers/installation_delete_params.rbs +0 -32
  155. data/sig/scalar_api_ruby/models/mcp/servers/installation_list_params.rbs +0 -27
  156. data/sig/scalar_api_ruby/models/mcp/servers/installation_list_response.rbs +0 -12
  157. data/sig/scalar_api_ruby/models/mcp/servers/installation_retrieve_params.rbs +0 -32
  158. data/sig/scalar_api_ruby/models/mcp/servers/installation_update_params.rbs +0 -73
  159. data/sig/scalar_api_ruby/models/mcp/servers/mcp_installation_list_item.rbs +0 -44
  160. data/sig/scalar_api_ruby/resources/mcp/servers/installations.rbs +0 -62
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ca656b63f726b635c22eaf8a467887b36d8ee8d0bd04482f6435201d0cc741d9
4
- data.tar.gz: c31f63ed06ef447bdd0f7cf1cfbce906610fd893d54a17a7dcde1cc9e9d4b1da
3
+ metadata.gz: 01b5564034ac23e6e3acdfcee6756bd477803ee8d1d16aae1c01c6081739421a
4
+ data.tar.gz: 8e50ff960d4ba614d8aa9bec5543815d4f9886abff7f5a1ecc208b774dc0519a
5
5
  SHA512:
6
- metadata.gz: 3c129c29701784cc2b66875a237ea3d51a8be09b0e28668d33fece42ef52fa909e84adb7ac0e08f3de6146e9c891ae202d943a2f67d8fc6739e83bbdc97156ff
7
- data.tar.gz: de21b5a90c763ebb11dfe7ddc5cc1e8e7ee85bb2071ea2733445a29c8564a77ee1d7628db88467a6a48a08f561c46492ab3e43c35b7a9d2612f01392b165e7b8
6
+ metadata.gz: bd48203908350f9af51ea0f2fdc2b8545caae65a4dbc2e8d7e416f96d4132d799b0bd783ced2828c6d7bde535277e209a8f45355a680472431f9a44d24776416
7
+ data.tar.gz: dc7bf9db3cf02f274f2e97a0b2a59c3fdbad21d4f9d27f4f7d7f59cec1db4014467ef951c43dfbf0b89ec1ea806218a69a3801b537acef85c4c59bda9041bc67
data/CHANGELOG.md CHANGED
@@ -1,5 +1,76 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.3.0](https://github.com/scalar/scalar-ruby/compare/v0.2.0...v0.3.0) (2026-11-25)
4
+
5
+
6
+ ### ⚠ BREAKING CHANGES
7
+
8
+ * **api:** request-shape POST v1/sdks.languages — required in before only (review: direction-dependent; read the hunk)
9
+ * **api:** 18 breaking changes to the SDK surface.
10
+ - operation-coverage DELETE v1/mcp/servers/{p} — operation only in before (breaking: the new snapshot no longer has it)
11
+ - operation-coverage DELETE v1/mcp/servers/{p}/installations/{p} — operation only in before (breaking: the new snapshot no longer has it)
12
+ - operation-coverage DELETE v1/mcp/servers/{p}/installations/{p}/access-group — operation only in before (breaking: the new snapshot no longer has it)
13
+ - operation-coverage GET v1/mcp/servers/{p} — operation only in before (breaking: the new snapshot no longer has it)
14
+ - operation-coverage GET v1/mcp/servers/{p}/installations — operation only in before (breaking: the new snapshot no longer has it)
15
+ - operation-coverage GET v1/mcp/servers/{p}/installations/{p} — operation only in before (breaking: the new snapshot no longer has it)
16
+ - operation-coverage PATCH v1/mcp/servers/{p} — operation only in before (breaking: the new snapshot no longer has it)
17
+ - operation-coverage PATCH v1/mcp/servers/{p}/installations/{p} — operation only in before (breaking: the new snapshot no longer has it)
18
+ - operation-coverage POST v1/mcp/servers/{p}/installations/{p}/access-group — operation only in before (breaking: the new snapshot no longer has it)
19
+ - response-shape POST v1/mcp/servers→.server.id — field only in before (breaking: removed; uid, domain, namespace appeared in its place, likely a rename)
20
+ - response-shape POST v1/mcp/servers→.installation — field only in before (breaking: the new snapshot no longer has it)
21
+ - types-files Mcp::Servers — type file only in before (8 members: 0 matched by name and kind elsewhere in after, 8 not found) (breaking: removed; ServerListResponseItem appeared in its place, likely a rename)
22
+ - types-classes (top-level):McpInstallation — alias only in before (breaking: the new snapshot no longer has it)
23
+ - types-classes Mcp:McpInstallation — class only in before (breaking: removed; ServerListResponseItem appeared in its place, likely a rename)
24
+ - types-classes Mcp:ServerDeleteParams — class only in before (breaking: removed; ServerListResponseItem appeared in its place, likely a rename)
25
+ - types-classes Mcp:ServerRetrieveParams — class only in before (breaking: removed; ServerListResponseItem appeared in its place, likely a rename)
26
+ - types-classes Mcp:ServerUpdateParams — class only in before (breaking: removed; ServerListResponseItem appeared in its place, likely a rename)
27
+ - types-classes Mcp:Servers — module only in before (breaking: removed; ServerListResponseItem appeared in its place, likely a rename)
28
+ * **api:** 9 breaking changes to the SDK surface.
29
+ - Added required property `sdk.current`.
30
+ - Property `sdk.currentVersion` type changed from `version` to `string`.
31
+ - Added required property `sdk.latestVersion`.
32
+ - Removed optional property `sdk.apiVersion`.
33
+ - Property `sdk_version.version` type changed from `version` to `string`.
34
+ - Property `sdk_version.createdAt` is now required.
35
+ - Removed required property `sdk_version.apiVersion`.
36
+ - Removed required property `sdk_version.status`.
37
+ - Removed optional property `sdk_version.publishedAt`.
38
+ * **api:** Added required property `github_project.chatInsightsEnabled`.
39
+ * **api:** 3 breaking changes to the SDK surface.
40
+ - Property `api_document.tags` type changed from `string` to `unknown`.
41
+ - Property `github_project.accessGroups` type changed from `string` to `unknown`.
42
+ - Property `docs_project.accessGroups` type changed from `string` to `unknown`.
43
+ * **api:** 8 breaking changes to the SDK surface.
44
+ - Removed body field `autoAddOperations` from `mcp.servers.update`.
45
+ - Removed body field `isPrivate` from `mcp.servers.installations.update`.
46
+ - Removed body field `loginPortalUid` from `mcp.servers.installations.update`.
47
+ - Removed body field `documentAuth` from `mcp.servers.installations.update`.
48
+ - Removed operation `mcp.servers.installations.create` (`POST /v1/mcp/servers/{id}/installations`).
49
+ - Removed required property `mcp_server.autoAddOperations`.
50
+ - Removed required property `mcp_installation.isPrivate`.
51
+ - Removed required property `mcp_installation_list_item.isPrivate`.
52
+
53
+ ### Features
54
+
55
+ * **api:** add property github_project.chatInsightsEnabled ([1acf1ad](https://github.com/scalar/scalar-ruby/commit/1acf1adc46ed34f558192d2f390a91c65e81b002))
56
+ * **api:** add property sdk.current (+9 more changes) ([08ed34e](https://github.com/scalar/scalar-ruby/commit/08ed34e0346e39f3c974c0e397f20571c2731830))
57
+ * **api:** update property api_document.tags (+3 more changes) ([cc500dd](https://github.com/scalar/scalar-ruby/commit/cc500dd9100311ce4fc7c9bc3324b376660b0dd2))
58
+ * **api:** update SDK surface (14 changes) ([637c4b1](https://github.com/scalar/scalar-ruby/commit/637c4b1ec12d07468051b91ce9d3e2f2a7a65cd9))
59
+ * **api:** update SDK surface (23 changes) ([b6bf4a4](https://github.com/scalar/scalar-ruby/commit/b6bf4a4f27d8588e61e7039527051317486c8356))
60
+ * **api:** update SDK surface (3 changes) ([5959802](https://github.com/scalar/scalar-ruby/commit/59598020add7766641907d6d9e55c240b8224b2f))
61
+ * **api:** update SDK surface (3 changes) ([b55255e](https://github.com/scalar/scalar-ruby/commit/b55255e63fc83b1c04db02d958734e018c5fcd46))
62
+ * **api:** update SDK surface (4 changes) ([3d717a5](https://github.com/scalar/scalar-ruby/commit/3d717a527d015d58902aa90c23acf4b9a2ef676c))
63
+
64
+
65
+ ### Chores
66
+
67
+ * **api:** regenerate SDK ([10173ff](https://github.com/scalar/scalar-ruby/commit/10173ffe92ca9e057ea40860775b8532d8bef22a))
68
+ * **api:** regenerate SDK ([32b876c](https://github.com/scalar/scalar-ruby/commit/32b876c3d61a1931678d3b30de1a5608d324ebfe))
69
+ * **api:** regenerate SDK ([5834062](https://github.com/scalar/scalar-ruby/commit/58340624e19ec64e59b11426a79d5ff2eedf96fc))
70
+ * **api:** regenerate SDK ([ef2020a](https://github.com/scalar/scalar-ruby/commit/ef2020a155d2a459c1d5681803fb7ae27e32d6ab))
71
+ * **api:** update generated SDK content ([447bdd1](https://github.com/scalar/scalar-ruby/commit/447bdd11d61070d4bbb4a34a250240e4291cdd74))
72
+ * **api:** update generated SDK content ([c0790e6](https://github.com/scalar/scalar-ruby/commit/c0790e6e73dcebdfe0b1e74fbe618e19a610dfc7))
73
+
3
74
  ## [0.2.0](https://github.com/scalar/scalar-ruby/compare/v0.1.1...v0.2.0) (2026-10-09)
4
75
 
5
76
 
data/README.md CHANGED
@@ -26,7 +26,7 @@ The full API of this library can be found in [api.md](./api.md).
26
26
  Add the gem to your application's `Gemfile`:
27
27
 
28
28
  ```ruby
29
- gem "scalar_api_ruby", "~> 0.2.0" # x-release-please-version
29
+ gem "scalar_api_ruby", "~> 0.3.0" # x-release-please-version
30
30
  ```
31
31
 
32
32
  Or install it directly:
@@ -84,6 +84,8 @@ begin
84
84
  puts response.inspect
85
85
  rescue Scalar::Errors::APIError => error
86
86
  puts "#{error.status}: #{error.message}"
87
+ puts error.request_id if error.request_id
88
+ puts error.problem_details if error.problem_details
87
89
  raise
88
90
  end
89
91
  ```
@@ -112,7 +114,7 @@ client = Scalar::Client.new(
112
114
  | `base_url` | `String \| nil` | `ENV["SCALAR_BASE_URL"]` | Override the default API base URL. |
113
115
  | `max_retries` | `Integer` | `2` | Max number of retries to attempt after a failed retryable request. |
114
116
  | `timeout` | `Float` | `60.0` | Seconds to wait for a response before timing out. |
115
- | `initial_retry_delay` | `Float` | `0.5` | Seconds to wait before the first retry; later retries back off exponentially. |
117
+ | `initial_retry_delay` | `Float` | `0.5` | Base delay, in seconds, for retry backoff: the wait grows with the square of the retry count, so the first retry is sent right away. |
116
118
  | `max_retry_delay` | `Float` | `8.0` | Upper bound, in seconds, on the delay between retries. |
117
119
 
118
120
  <br />
@@ -121,7 +123,7 @@ client = Scalar::Client.new(
121
123
 
122
124
  | Option | Type | Default | Description |
123
125
  | --- | --- | --- | --- |
124
- | `idempotency_key` | `String` | - | Idempotency key for one request, sent when the SDK configures an idempotency header. |
126
+ | `idempotency_key` | `String` | - | Idempotency key for one request. This SDK configures no idempotency header, so it is not sent. |
125
127
  | `extra_query` | `Hash` | - | Additional query parameters for one request. |
126
128
  | `extra_headers` | `Hash` | - | Additional headers for one request. |
127
129
  | `extra_body` | `Hash` | - | Additional body fields for one request. |
data/SKILL.md CHANGED
@@ -12,7 +12,7 @@ Generated Ruby client for Scalar API, published as `scalar_api_ruby`. Use the ge
12
12
  Add the gem to your application's `Gemfile`:
13
13
 
14
14
  ```ruby
15
- gem "scalar_api_ruby", "~> 0.2.0" # x-release-please-version
15
+ gem "scalar_api_ruby", "~> 0.3.0" # x-release-please-version
16
16
  ```
17
17
 
18
18
  Or install it directly:
@@ -63,6 +63,8 @@ begin
63
63
  puts response.inspect
64
64
  rescue Scalar::Errors::APIError => error
65
65
  puts "#{error.status}: #{error.message}"
66
+ puts error.request_id if error.request_id
67
+ puts error.problem_details if error.problem_details
66
68
  raise
67
69
  end
68
70
  ```
data/api.md CHANGED
@@ -105,17 +105,6 @@ Complete reference of every operation, grouped by resource. See [the README](./R
105
105
  - [`Mcp Servers`](#mcp-servers)
106
106
  - [List all MCP servers](#list-all-mcp-servers)
107
107
  - [Create an MCP server](#create-an-mcp-server)
108
- - [Get an MCP server](#get-an-mcp-server)
109
- - [Update an MCP server](#update-an-mcp-server)
110
- - [Delete an MCP server](#delete-an-mcp-server)
111
- - [`Mcp Servers Installations`](#mcp-servers-installations)
112
- - [List installations](#list-installations)
113
- - [Create an installation](#create-an-installation)
114
- - [Get an installation](#get-an-installation)
115
- - [Update an installation](#update-an-installation)
116
- - [Delete an installation](#delete-an-installation)
117
- - [Add an access group](#add-an-access-group)
118
- - [Remove an access group](#remove-an-access-group)
119
108
 
120
109
  ## Setup
121
110
 
@@ -503,7 +492,7 @@ Create a login portal for the current team.
503
492
  | Response | [`UID`](././lib/scalar_api_ruby/models/uid.rb) |
504
493
 
505
494
  ```ruby
506
- response = client.login_portals.create({ email: { "logo" => "", "logoSize" => "100", "buttonText" => "Login", "message" => "Click to access private documentation hosted by scalar.com", "title" => "Private Docs", "mainColor" => "\#2a2f45", "mainBackground" => "\#f6f6f6", "cardColor" => "\#2a2f45", "cardBackground" => "\#fff", "buttonColor" => "\#fff", "buttonBackground" => "\#0f0f0f" }, page: { "title" => "Scalar Private Docs", "description" => "Login to access your documentation", "head" => "", "script" => "", "theme" => "", "companyName" => "", "logo" => "", "logoURL" => "", "favicon" => "", "termsLink" => "", "privacyLink" => "", "formTitle" => "Scalar Private Docs", "formDescription" => "Login to access your documentation", "formImage" => "" }, slug: "acme-login", title: "Acme Private Documentation" })
495
+ response = client.login_portals.create({ email: { "logo" => "", "logoSize" => "100", "buttonText" => "Login", "message" => "Click to access private documentation hosted by scalar.com", "title" => "Private Docs", "mainColor" => "#2a2f45", "mainBackground" => "#f6f6f6", "cardColor" => "#2a2f45", "cardBackground" => "#fff", "buttonColor" => "#fff", "buttonBackground" => "#0f0f0f" }, page: { "title" => "Scalar Private Docs", "description" => "Login to access your documentation", "head" => "", "script" => "", "theme" => "", "companyName" => "", "logo" => "", "logoURL" => "", "favicon" => "", "termsLink" => "", "privacyLink" => "", "formTitle" => "Scalar Private Docs", "formDescription" => "Login to access your documentation", "formImage" => "" }, slug: "acme-login", title: "Acme Private Documentation" })
507
496
 
508
497
  puts response.inspect
509
498
  ```
@@ -750,7 +739,7 @@ Create a team theme.
750
739
  | Response | [`UID`](././lib/scalar_api_ruby/models/uid.rb) |
751
740
 
752
741
  ```ruby
753
- response = client.themes.create({ document: ":root { --scalar-color-1: \#1f2937; }", name: "Acme Theme", slug: "acme-theme", description: "API for managing Acme products and orders." })
742
+ response = client.themes.create({ document: ":root { --scalar-color-1: #1f2937; }", name: "Acme Theme", slug: "acme-theme", description: "API for managing Acme products and orders." })
754
743
 
755
744
  puts response.inspect
756
745
  ```
@@ -778,7 +767,7 @@ Replace the theme document.
778
767
  | Request | [`ThemeReplaceDocumentParams`](././lib/scalar_api_ruby/models/theme_replace_document_params.rb) |
779
768
 
780
769
  ```ruby
781
- response = client.themes.replace_document("acme-theme", { document: ":root { --scalar-color-1: \#1f2937; }" })
770
+ response = client.themes.replace_document("acme-theme", { document: ":root { --scalar-color-1: #1f2937; }" })
782
771
 
783
772
  puts response.inspect
784
773
  ```
@@ -1178,7 +1167,7 @@ SDKs
1178
1167
 
1179
1168
  ### List all SDKs
1180
1169
 
1181
- List every SDK on the team.
1170
+ List every SDK on the team. `targets` are the languages its config declares, which the next build builds. `current` (the version label per language a request without a version serves) and each version label’s `languages`, highest label first, are what is served, and can include a language a later config dropped: a version keeps the languages its builds produced. Also returns the `currentVersion` and `latestVersion` tags.
1182
1171
 
1183
1172
  | Direction | Type |
1184
1173
  | --- | --- |
@@ -1193,7 +1182,7 @@ puts response.inspect
1193
1182
 
1194
1183
  ### Create an SDK
1195
1184
 
1196
- Create an SDK from an API document, targeting one or more languages.
1185
+ Create an SDK from an existing API document on the team. Its current version must have content. Send languages or a config declaring targets; omit languages to derive them from config. SDK and target counts must fit the team plan. Config is a JSON string.
1197
1186
 
1198
1187
  | Direction | Type |
1199
1188
  | --- | --- |
@@ -1201,14 +1190,14 @@ Create an SDK from an API document, targeting one or more languages.
1201
1190
  | Response | [`UID`](././lib/scalar_api_ruby/models/uid.rb) |
1202
1191
 
1203
1192
  ```ruby
1204
- response = client.sdks.create({ api_uid: "UakgbKJ5m9gl0JDMbcJqL", languages: ["typescript"], class_name: "Acme", config: "{\"targets\":{\"typescript\":{\"packageName\":\"@acme/sdk\"}}}", slug: "acme-api", title: "Acme SDK" })
1193
+ response = client.sdks.create({ api_uid: "UakgbKJ5m9gl0JDMbcJqL", class_name: "Acme", config: "{\"targets\":{\"typescript\":{\"packageName\":\"@acme/sdk\"}}}", languages: ["typescript"], slug: "acme-api", title: "Acme SDK" })
1205
1194
 
1206
1195
  puts response.inspect
1207
1196
  ```
1208
1197
 
1209
1198
  ### Get an SDK
1210
1199
 
1211
- Get a single SDK by its uid.
1200
+ Get a single SDK by its uid. `targets` are the languages its config declares, which the next build builds. `current` (the version label per language a request without a version serves) and each version label’s `languages`, highest label first, are what is served, and can include a language a later config dropped: a version keeps the languages its builds produced. Also returns the `currentVersion` and `latestVersion` tags.
1212
1201
 
1213
1202
  | Direction | Type |
1214
1203
  | --- | --- |
@@ -1223,14 +1212,14 @@ puts response.inspect
1223
1212
 
1224
1213
  ### Update an SDK
1225
1214
 
1226
- Update SDK metadata, its linked API, or its config.
1215
+ Update SDK metadata, its linked API, or its JSON-string config. Targets using native GitHub delivery need separate repositories; delivery writes each package at the repository root. Sharing a repository across language targets in this SDK and using reserved promote branches are rejected before config saves.
1227
1216
 
1228
1217
  | Direction | Type |
1229
1218
  | --- | --- |
1230
1219
  | Request | [`SdkUpdateParams`](././lib/scalar_api_ruby/models/sdk_update_params.rb) |
1231
1220
 
1232
1221
  ```ruby
1233
- response = client.sdks.update("UakgbKJ5m9gl0JDMbcJqL", { api_uid: "UakgbKJ5m9gl0JDMbcJqL", api_version: "", config: "{\"targets\":{\"typescript\":{\"packageName\":\"@acme/sdk\"}}}", is_private: false, slug: "acme-api", title: "Acme SDK" })
1222
+ response = client.sdks.update("UakgbKJ5m9gl0JDMbcJqL", { api_uid: "UakgbKJ5m9gl0JDMbcJqL", api_version: { }, config: "{\"targets\":{\"typescript\":{\"packageName\":\"@acme/sdk\"}}}", is_private: false, slug: "acme-api", title: "Acme SDK" })
1234
1223
 
1235
1224
  puts response.inspect
1236
1225
  ```
@@ -1251,7 +1240,7 @@ puts response.inspect
1251
1240
 
1252
1241
  ### Build an SDK
1253
1242
 
1254
- Start a build. Omit `version` to build the current work — the open draft, else the latest version — and the resolved version comes back in the response.
1243
+ Start a build with the SDK's saved config. Every input is optional: `version` is the version of the linked API description to build (default: its latest version), `customCodeRef` the branch, tag or commit each language merges as custom code (default: each language's `scalar-next` branch), and `languages` the languages to build (default: every language the config declares). The response names the version built. A 503 means the custom code could not be read from GitHub and nothing was built; try again.
1255
1244
 
1256
1245
  | Direction | Type |
1257
1246
  | --- | --- |
@@ -1259,7 +1248,7 @@ Start a build. Omit `version` to build the current work — the open draft, else
1259
1248
  | Response | [`SdkBuildResponse`](././lib/scalar_api_ruby/models/sdk_build_response.rb) |
1260
1249
 
1261
1250
  ```ruby
1262
- response = client.sdks.build("UakgbKJ5m9gl0JDMbcJqL", { languages: ["typescript"], version: "1.2.0" })
1251
+ response = client.sdks.build("UakgbKJ5m9gl0JDMbcJqL", { custom_code_ref: "scalar-next", languages: ["typescript"], version: "1.2.0" })
1263
1252
 
1264
1253
  puts response.inspect
1265
1254
  ```
@@ -1270,21 +1259,21 @@ SDKs
1270
1259
 
1271
1260
  #### Create an SDK version
1272
1261
 
1273
- Create a new SDK version against a specific API version.
1262
+ Create a version label from a version of the SDK's API document and start its build. The label is the document version, and it becomes `latestVersion` when it is the highest.
1274
1263
 
1275
1264
  | Direction | Type |
1276
1265
  | --- | --- |
1277
1266
  | Request | [`VersionCreateParams`](././lib/scalar_api_ruby/models/sdks/version_create_params.rb) |
1278
1267
 
1279
1268
  ```ruby
1280
- response = client.sdks.versions.create("UakgbKJ5m9gl0JDMbcJqL", { api_version: "1.2.0", version: "1.2.0" })
1269
+ response = client.sdks.versions.create("UakgbKJ5m9gl0JDMbcJqL", { version: "1.2.0", api_version: { } })
1281
1270
 
1282
1271
  puts response.inspect
1283
1272
  ```
1284
1273
 
1285
1274
  #### Delete an SDK version
1286
1275
 
1287
- Permanently delete one version of an SDK.
1276
+ Permanently delete one version label of an SDK and its builds. A label that is the current build of any language promoting manually is refused with 409 and nothing is deleted; promote or roll back to another build for that language first. Each other language whose current build was of that label moves to the active build of the highest remaining label that has one for the language, and has no current build when none has; `currentVersion` shows the result. Each language that moved to another build syncs it to its linked repository unless the repository already holds it. When it was `latestVersion`, that tag moves to the highest remaining label holding an active build. An SDK's last version cannot be deleted.
1288
1277
 
1289
1278
  | Direction | Type |
1290
1279
  | --- | --- |
@@ -1302,7 +1291,7 @@ SDKs
1302
1291
 
1303
1292
  #### Link a repository
1304
1293
 
1305
- Link one language target to a GitHub repository, so builds sync there.
1294
+ Link an existing language target to a GitHub repository accessible through the Scalar GitHub App. Requires team edit permission and a paid SDK automation plan. Native delivery writes at the repository root; use a separate repository for each target. Directory fields are unsupported. Linking can immediately sync the current build under automatic promotion; pass promotion: manual to hold it back. If GitHub access is missing, connect GitHub and grant the App access in Scalar Dashboard before retrying.
1306
1295
 
1307
1296
  | Direction | Type |
1308
1297
  | --- | --- |
@@ -1310,7 +1299,7 @@ Link one language target to a GitHub repository, so builds sync there.
1310
1299
  | Response | [`Sdks::RepositoryLinkResponse`](././lib/scalar_api_ruby/models/sdks/repository_link_response.rb) |
1311
1300
 
1312
1301
  ```ruby
1313
- response = client.sdks.repositories.link("UakgbKJ5m9gl0JDMbcJqL", { base_branch: "main", language: "typescript", repository_id: 123456789, prerelease_type: "beta" })
1302
+ response = client.sdks.repositories.link("UakgbKJ5m9gl0JDMbcJqL", { base_branch: "main", language: "typescript", repository_id: 123456789, prerelease_type: "beta", promotion: "automatic" })
1314
1303
 
1315
1304
  puts response.inspect
1316
1305
  ```
@@ -1338,7 +1327,7 @@ Toggle publish-on-merge and the release settings for a linked target.
1338
1327
  | Request | [`RepositoryUpdatePublishingParams`](././lib/scalar_api_ruby/models/sdks/repository_update_publishing_params.rb) |
1339
1328
 
1340
1329
  ```ruby
1341
- response = client.sdks.repositories.update_publishing("typescript", { uid: "UakgbKJ5m9gl0JDMbcJqL", publish_on_merge: true, access: "public", auth_method: "oidc", tag: "latest" })
1330
+ response = client.sdks.repositories.update_publishing("typescript", { uid: "UakgbKJ5m9gl0JDMbcJqL", publish_on_merge: true, access: "public", artifact_id: "scalar-galaxy", auth_method: "oidc", cask: true, registry: "npm", replace_formula: false, tag: "latest", tap_repo: "scalar/homebrew-tap" })
1342
1331
 
1343
1332
  puts response.inspect
1344
1333
  ```
@@ -1351,12 +1340,12 @@ MCP
1351
1340
 
1352
1341
  #### List all MCP servers
1353
1342
 
1354
- List every MCP server on the team.
1343
+ List every MCP server on the team, each with its environments and the version tag a request that names no version gets there.
1355
1344
 
1356
1345
  | Direction | Type |
1357
1346
  | --- | --- |
1358
1347
  | Request | [`ServerListParams`](././lib/scalar_api_ruby/models/mcp/server_list_params.rb) |
1359
- | Response | [`Mcp::McpServer`](././lib/scalar_api_ruby/models/mcp/mcp_server.rb) |
1348
+ | Response | [`Mcp::ServerListResponseItem`](././lib/scalar_api_ruby/models/mcp/server_list_response.rb) |
1360
1349
 
1361
1350
  ```ruby
1362
1351
  response = client.mcp.servers.list
@@ -1366,7 +1355,7 @@ puts response.inspect
1366
1355
 
1367
1356
  #### Create an MCP server
1368
1357
 
1369
- Create an MCP server over one or more API document versions. The response carries the server and its first installation.
1358
+ Create an MCP server linking the API documents of the named versions and the named docs projects. The server builds from each linked document’s versions, not only the version named.
1370
1359
 
1371
1360
  | Direction | Type |
1372
1361
  | --- | --- |
@@ -1378,153 +1367,3 @@ response = client.mcp.servers.create({ name: "Acme MCP", project_uids: [""], slu
1378
1367
 
1379
1368
  puts response.inspect
1380
1369
  ```
1381
-
1382
- #### Get an MCP server
1383
-
1384
- Get a single MCP server by its id.
1385
-
1386
- | Direction | Type |
1387
- | --- | --- |
1388
- | Request | [`ServerRetrieveParams`](././lib/scalar_api_ruby/models/mcp/server_retrieve_params.rb) |
1389
- | Response | [`Mcp::McpServer`](././lib/scalar_api_ruby/models/mcp/mcp_server.rb) |
1390
-
1391
- ```ruby
1392
- response = client.mcp.servers.retrieve("42")
1393
-
1394
- puts response.inspect
1395
- ```
1396
-
1397
- #### Update an MCP server
1398
-
1399
- Update MCP server metadata and which tools it exposes.
1400
-
1401
- | Direction | Type |
1402
- | --- | --- |
1403
- | Request | [`ServerUpdateParams`](././lib/scalar_api_ruby/models/mcp/server_update_params.rb) |
1404
- | Response | [`Mcp::McpServer`](././lib/scalar_api_ruby/models/mcp/mcp_server.rb) |
1405
-
1406
- ```ruby
1407
- response = client.mcp.servers.update("42", { auto_add_operations: true, docs_pages: [""], name: "Acme MCP", operations: [""], slug: "acme-api" })
1408
-
1409
- puts response.inspect
1410
- ```
1411
-
1412
- #### Delete an MCP server
1413
-
1414
- Delete an MCP server and every installation it serves.
1415
-
1416
- | Direction | Type |
1417
- | --- | --- |
1418
- | Request | [`ServerDeleteParams`](././lib/scalar_api_ruby/models/mcp/server_delete_params.rb) |
1419
-
1420
- ```ruby
1421
- response = client.mcp.servers.delete("42")
1422
-
1423
- puts response.inspect
1424
- ```
1425
-
1426
- #### `Mcp Servers Installations`
1427
-
1428
- MCP
1429
-
1430
- ##### List installations
1431
-
1432
- List the installations of an MCP server. An installation is what an MCP client connects to.
1433
-
1434
- | Direction | Type |
1435
- | --- | --- |
1436
- | Request | [`InstallationListParams`](././lib/scalar_api_ruby/models/mcp/servers/installation_list_params.rb) |
1437
- | Response | [`Mcp::Servers::McpInstallationListItem`](././lib/scalar_api_ruby/models/mcp/servers/mcp_installation_list_item.rb) |
1438
-
1439
- ```ruby
1440
- response = client.mcp.servers.installations.list("42")
1441
-
1442
- puts response.inspect
1443
- ```
1444
-
1445
- ##### Create an installation
1446
-
1447
- Create an installation of an MCP server. `documentAuth` holds the credentials the server presents to the upstream API and is never returned.
1448
-
1449
- | Direction | Type |
1450
- | --- | --- |
1451
- | Request | [`InstallationCreateParams`](././lib/scalar_api_ruby/models/mcp/servers/installation_create_params.rb) |
1452
- | Response | [`Mcp::McpInstallation`](././lib/scalar_api_ruby/models/mcp/mcp_installation.rb) |
1453
-
1454
- ```ruby
1455
- response = client.mcp.servers.installations.create("42", { document_auth: { }, name: "Acme MCP", slug: "acme-api" })
1456
-
1457
- puts response.inspect
1458
- ```
1459
-
1460
- ##### Get an installation
1461
-
1462
- Get a single installation of an MCP server.
1463
-
1464
- | Direction | Type |
1465
- | --- | --- |
1466
- | Request | [`InstallationRetrieveParams`](././lib/scalar_api_ruby/models/mcp/servers/installation_retrieve_params.rb) |
1467
- | Response | [`Mcp::McpInstallation`](././lib/scalar_api_ruby/models/mcp/mcp_installation.rb) |
1468
-
1469
- ```ruby
1470
- response = client.mcp.servers.installations.retrieve("84", { id: "42" })
1471
-
1472
- puts response.inspect
1473
- ```
1474
-
1475
- ##### Update an installation
1476
-
1477
- Update an installation. Set `isPrivate` and add access groups to put it behind a login.
1478
-
1479
- | Direction | Type |
1480
- | --- | --- |
1481
- | Request | [`InstallationUpdateParams`](././lib/scalar_api_ruby/models/mcp/servers/installation_update_params.rb) |
1482
- | Response | [`Mcp::McpInstallation`](././lib/scalar_api_ruby/models/mcp/mcp_installation.rb) |
1483
-
1484
- ```ruby
1485
- response = client.mcp.servers.installations.update("84", { id: "42", document_auth: { }, is_private: false, login_portal_uid: "", mcp_version: "", name: "Acme MCP", slug: "acme-api" })
1486
-
1487
- puts response.inspect
1488
- ```
1489
-
1490
- ##### Delete an installation
1491
-
1492
- Delete an installation of an MCP server.
1493
-
1494
- | Direction | Type |
1495
- | --- | --- |
1496
- | Request | [`InstallationDeleteParams`](././lib/scalar_api_ruby/models/mcp/servers/installation_delete_params.rb) |
1497
-
1498
- ```ruby
1499
- response = client.mcp.servers.installations.delete("84", { id: "42" })
1500
-
1501
- puts response.inspect
1502
- ```
1503
-
1504
- ##### Add an access group
1505
-
1506
- Let an access group reach a private installation.
1507
-
1508
- | Direction | Type |
1509
- | --- | --- |
1510
- | Request | [`InstallationCreateAccessGroupParams`](././lib/scalar_api_ruby/models/mcp/servers/installation_create_access_group_params.rb) |
1511
-
1512
- ```ruby
1513
- response = client.mcp.servers.installations.create_access_group("84", { id: "42", access_group_uid: "UakgbKJ5m9gl0JDMbcJqL" })
1514
-
1515
- puts response.inspect
1516
- ```
1517
-
1518
- ##### Remove an access group
1519
-
1520
- Stop an access group reaching a private installation.
1521
-
1522
- | Direction | Type |
1523
- | --- | --- |
1524
- | Request | [`InstallationDeleteAccessGroupParams`](././lib/scalar_api_ruby/models/mcp/servers/installation_delete_access_group_params.rb) |
1525
-
1526
- ```ruby
1527
- response = client.mcp.servers.installations.delete_access_group("84", { id: "42", access_group_uid: "UakgbKJ5m9gl0JDMbcJqL" })
1528
-
1529
- puts response.inspect
1530
- ```
@@ -79,6 +79,8 @@ module Scalar
79
79
  #
80
80
  # @return [Hash{String=>String}]
81
81
  private def auth_bearer_auth
82
+ return {} if @bearer_auth.to_s.empty?
83
+
82
84
  {"authorization" => "Bearer #{@bearer_auth}"}
83
85
  end
84
86
 
@@ -86,9 +88,16 @@ module Scalar
86
88
  #
87
89
  # @return [Hash{String=>String}]
88
90
  private def auth_o_auth2
91
+ return {} if @o_auth2.to_s.empty?
92
+
89
93
  {"authorization" => "Bearer #{@o_auth2}"}
90
94
  end
91
95
 
96
+ # @api private
97
+ #
98
+ # @return [Array<String>]
99
+ private def auth_header_keys = ["authorization"]
100
+
92
101
  # Creates and returns a new client for interacting with the API.
93
102
  #
94
103
  # @param bearer_auth [String, nil] Defaults to `ENV["BEARER_AUTH"]`
@@ -120,12 +129,12 @@ module Scalar
120
129
  custom_headers_env = ENV["SCALAR_CUSTOM_HEADERS"]
121
130
  unless custom_headers_env.nil?
122
131
  parsed = {}
123
- custom_headers_env
124
- .split("\n")
125
- .each do |line|
126
- colon = line.index(":")
127
- parsed[line[0...colon].strip] = line[(colon + 1)..].strip unless colon.nil?
132
+ custom_headers_env.split("\n").each do |line|
133
+ colon = line.index(":")
134
+ unless colon.nil?
135
+ parsed[line[0...colon].strip] = line[(colon + 1)..].strip
128
136
  end
137
+ end
129
138
  headers = parsed.merge(headers)
130
139
  end
131
140
 
@@ -46,6 +46,28 @@ module Scalar
46
46
  # @return [Object, nil]
47
47
  attr_accessor :body
48
48
 
49
+ # Request identifier exposed by common API response headers, matched case-insensitively.
50
+ # @return [String, nil]
51
+ def request_id
52
+ response_header("x-request-id") || response_header("request-id") ||
53
+ response_header("x-correlation-id")
54
+ end
55
+
56
+ # Parsed RFC 7807 body for application/problem+json responses, preserving extension fields.
57
+ # Non-object bodies and other media types are not treated as Problem Details.
58
+ # @return [Hash{String, Symbol=>Object}, nil]
59
+ def problem_details
60
+ media_type = response_header("content-type").to_s.split(";", 2).first.to_s.strip.downcase
61
+ @body if media_type == "application/problem+json" && @body.is_a?(Hash)
62
+ end
63
+
64
+ # Header maps supplied directly by callers need not use the transport's lowercase spelling.
65
+ # @param name [String]
66
+ # @return [String, nil]
67
+ private def response_header(name)
68
+ @headers&.find { |key, _| key.to_s.downcase == name }&.last
69
+ end
70
+
49
71
  # @api private
50
72
  #
51
73
  # @param url [URI::Generic]
@@ -37,10 +37,22 @@ module Scalar
37
37
  # @return [String]
38
38
  def to_yaml(*a) = read.to_yaml(*a)
39
39
 
40
+ # The filename sent for a part is only ever a basename: an open `File` knows the full local path
41
+ # it was opened from, which is the caller's business and not the server's.
42
+ #
43
+ # The content type is written into the part's headers as given, so one carrying a control
44
+ # character (a CR or LF would start a header line of its own) is refused here, before any request.
45
+ #
40
46
  # @param content [Pathname, StringIO, IO, String]
41
47
  # @param filename [Pathname, String, nil]
42
48
  # @param content_type [String, nil]
49
+ #
50
+ # @raise [ArgumentError] when `content_type` contains a control character
43
51
  def initialize(content, filename: nil, content_type: nil)
52
+ if content_type&.to_s&.match?(/[\x00-\x1F\x7F]/)
53
+ raise ArgumentError.new("The content type #{content_type.inspect} contains a control character.")
54
+ end
55
+
44
56
  @content_type = content_type
45
57
  @filename =
46
58
  case [filename, (@content = content)]
@@ -49,7 +61,7 @@ module Scalar
49
61
  in [nil, Pathname]
50
62
  content.basename.to_path
51
63
  in [nil, IO]
52
- content.to_path
64
+ content.respond_to?(:to_path) ? ::File.basename(content.to_path) : nil
53
65
  else
54
66
  filename
55
67
  end