skooma 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (86) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +22 -0
  3. data/LICENSE.txt +21 -0
  4. data/README.md +125 -0
  5. data/data/oas-3.1/dialect/base.json +25 -0
  6. data/data/oas-3.1/meta/base.json +96 -0
  7. data/data/oas-3.1/schema/2022-10-07.json +1441 -0
  8. data/data/oas-3.1/schema-base/2022-10-07.json +23 -0
  9. data/lib/skooma/body_parsers.rb +31 -0
  10. data/lib/skooma/dialects/oas_3_1.rb +41 -0
  11. data/lib/skooma/inflector.rb +19 -0
  12. data/lib/skooma/instance.rb +112 -0
  13. data/lib/skooma/keywords/oas_3_1/dialect/discriminator.rb +13 -0
  14. data/lib/skooma/keywords/oas_3_1/dialect/example.rb +13 -0
  15. data/lib/skooma/keywords/oas_3_1/dialect/external_docs.rb +13 -0
  16. data/lib/skooma/keywords/oas_3_1/dialect/xml.rb +13 -0
  17. data/lib/skooma/keywords/oas_3_1/schema.rb +32 -0
  18. data/lib/skooma/keywords/oas_3_1.rb +22 -0
  19. data/lib/skooma/objects/base/keywords/deprecated.rb +13 -0
  20. data/lib/skooma/objects/base/keywords/description.rb +13 -0
  21. data/lib/skooma/objects/base/keywords/security.rb +13 -0
  22. data/lib/skooma/objects/base/keywords/servers.rb +13 -0
  23. data/lib/skooma/objects/base/keywords/summary.rb +13 -0
  24. data/lib/skooma/objects/base/keywords/tags.rb +13 -0
  25. data/lib/skooma/objects/base.rb +33 -0
  26. data/lib/skooma/objects/callback.rb +12 -0
  27. data/lib/skooma/objects/components.rb +30 -0
  28. data/lib/skooma/objects/header/keywords/content.rb +50 -0
  29. data/lib/skooma/objects/header/keywords/example.rb +13 -0
  30. data/lib/skooma/objects/header/keywords/examples.rb +13 -0
  31. data/lib/skooma/objects/header/keywords/explode.rb +13 -0
  32. data/lib/skooma/objects/header/keywords/required.rb +19 -0
  33. data/lib/skooma/objects/header/keywords/schema.rb +19 -0
  34. data/lib/skooma/objects/header/keywords/style.rb +13 -0
  35. data/lib/skooma/objects/header.rb +23 -0
  36. data/lib/skooma/objects/media_type.rb +14 -0
  37. data/lib/skooma/objects/openapi/keywords/components.rb +23 -0
  38. data/lib/skooma/objects/openapi/keywords/info.rb +13 -0
  39. data/lib/skooma/objects/openapi/keywords/json_schema_dialect.rb +21 -0
  40. data/lib/skooma/objects/openapi/keywords/openapi.rb +24 -0
  41. data/lib/skooma/objects/openapi/keywords/paths.rb +62 -0
  42. data/lib/skooma/objects/openapi/keywords/security.rb +13 -0
  43. data/lib/skooma/objects/openapi/keywords/webhooks.rb +15 -0
  44. data/lib/skooma/objects/openapi.rb +39 -0
  45. data/lib/skooma/objects/operation/keywords/callbacks.rb +13 -0
  46. data/lib/skooma/objects/operation/keywords/operation_id.rb +13 -0
  47. data/lib/skooma/objects/operation/keywords/parameters.rb +53 -0
  48. data/lib/skooma/objects/operation/keywords/request_body.rb +21 -0
  49. data/lib/skooma/objects/operation/keywords/responses.rb +48 -0
  50. data/lib/skooma/objects/operation.rb +31 -0
  51. data/lib/skooma/objects/parameter/keywords/allow_empty_value.rb +13 -0
  52. data/lib/skooma/objects/parameter/keywords/allow_reserved.rb +13 -0
  53. data/lib/skooma/objects/parameter/keywords/content.rb +21 -0
  54. data/lib/skooma/objects/parameter/keywords/in.rb +13 -0
  55. data/lib/skooma/objects/parameter/keywords/name.rb +13 -0
  56. data/lib/skooma/objects/parameter/keywords/required.rb +19 -0
  57. data/lib/skooma/objects/parameter/keywords/schema.rb +21 -0
  58. data/lib/skooma/objects/parameter/keywords/value_parser.rb +80 -0
  59. data/lib/skooma/objects/parameter.rb +27 -0
  60. data/lib/skooma/objects/path_item/keywords/base_operation.rb +25 -0
  61. data/lib/skooma/objects/path_item/keywords/delete.rb +16 -0
  62. data/lib/skooma/objects/path_item/keywords/get.rb +16 -0
  63. data/lib/skooma/objects/path_item/keywords/head.rb +16 -0
  64. data/lib/skooma/objects/path_item/keywords/options.rb +16 -0
  65. data/lib/skooma/objects/path_item/keywords/parameters.rb +19 -0
  66. data/lib/skooma/objects/path_item/keywords/patch.rb +16 -0
  67. data/lib/skooma/objects/path_item/keywords/post.rb +16 -0
  68. data/lib/skooma/objects/path_item/keywords/put.rb +16 -0
  69. data/lib/skooma/objects/path_item/keywords/trace.rb +16 -0
  70. data/lib/skooma/objects/path_item.rb +28 -0
  71. data/lib/skooma/objects/ref_base.rb +33 -0
  72. data/lib/skooma/objects/request_body/keywords/required.rb +19 -0
  73. data/lib/skooma/objects/request_body.rb +17 -0
  74. data/lib/skooma/objects/response/keywords/content.rb +51 -0
  75. data/lib/skooma/objects/response/keywords/headers.rb +37 -0
  76. data/lib/skooma/objects/response/keywords/links.rb +13 -0
  77. data/lib/skooma/objects/response.rb +18 -0
  78. data/lib/skooma/output_format.rb +35 -0
  79. data/lib/skooma/rspec.rb +166 -0
  80. data/lib/skooma/validators/double.rb +13 -0
  81. data/lib/skooma/validators/float.rb +13 -0
  82. data/lib/skooma/validators/int_32.rb +15 -0
  83. data/lib/skooma/validators/int_64.rb +15 -0
  84. data/lib/skooma/version.rb +5 -0
  85. data/lib/skooma.rb +26 -0
  86. metadata +161 -0
@@ -0,0 +1,23 @@
1
+ {
2
+ "$id": "https://spec.openapis.org/oas/3.1/schema-base/2022-10-07",
3
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
4
+
5
+ "description": "The description of OpenAPI v3.1.x documents using the OpenAPI JSON Schema dialect, as defined by https://spec.openapis.org/oas/v3.1.0",
6
+
7
+ "$ref": "https://spec.openapis.org/oas/3.1/schema/2022-10-07",
8
+ "properties": {
9
+ "jsonSchemaDialect": { "$ref": "#/$defs/dialect" }
10
+ },
11
+
12
+ "$defs": {
13
+ "dialect": { "const": "https://spec.openapis.org/oas/3.1/dialect/base" },
14
+
15
+ "schema": {
16
+ "$dynamicAnchor": "meta",
17
+ "$ref": "https://spec.openapis.org/oas/3.1/dialect/base",
18
+ "properties": {
19
+ "$schema": { "$ref": "#/$defs/dialect" }
20
+ }
21
+ }
22
+ }
23
+ }
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Skooma
4
+ module BodyParsers
5
+ class << self
6
+ DEFAULT_PARSER = ->(body) { body }
7
+
8
+ def [](media_type)
9
+ parsers[media_type.to_s.strip.downcase] || DEFAULT_PARSER
10
+ end
11
+
12
+ attr_accessor :parsers
13
+
14
+ def register(*media_types, parser)
15
+ media_types.each do |media_type|
16
+ parsers[media_type.to_s.strip.downcase] = parser
17
+ end
18
+ end
19
+ end
20
+ self.parsers = {}
21
+
22
+ module JSONParser
23
+ def self.call(body)
24
+ JSON.parse(body)
25
+ rescue JSON::ParserError
26
+ body
27
+ end
28
+ end
29
+ register "application/json", JSONParser
30
+ end
31
+ end
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Skooma
4
+ module Dialects
5
+ module OAS31
6
+ class << self
7
+ def call(registry, **options)
8
+ registry.add_source(
9
+ "https://spec.openapis.org/oas/3.1/",
10
+ JSONSkooma::Sources::Local.new(File.join(DATA_DIR, "oas-3.1").to_s, suffix: ".json")
11
+ )
12
+
13
+ registry.add_vocabulary(
14
+ "https://spec.openapis.org/oas/3.1/vocab/base",
15
+ Skooma::Keywords::OAS31::Dialect::Discriminator,
16
+ Skooma::Keywords::OAS31::Dialect::Xml,
17
+ Skooma::Keywords::OAS31::Dialect::ExternalDocs,
18
+ Skooma::Keywords::OAS31::Dialect::Example
19
+ )
20
+
21
+ registry.add_metaschema(
22
+ "https://spec.openapis.org/oas/3.1/dialect/base",
23
+ "https://json-schema.org/draft/2020-12/vocab/core",
24
+ "https://json-schema.org/draft/2020-12/vocab/applicator",
25
+ "https://json-schema.org/draft/2020-12/vocab/unevaluated",
26
+ "https://json-schema.org/draft/2020-12/vocab/validation",
27
+ "https://json-schema.org/draft/2020-12/vocab/format-annotation",
28
+ "https://json-schema.org/draft/2020-12/vocab/meta-data",
29
+ "https://json-schema.org/draft/2020-12/vocab/content",
30
+ "https://spec.openapis.org/oas/3.1/vocab/base"
31
+ )
32
+
33
+ registry.add_format("int32", Skooma::Validators::Int32)
34
+ registry.add_format("int64", Skooma::Validators::Int64)
35
+ registry.add_format("float", Skooma::Validators::Float)
36
+ registry.add_format("double", Skooma::Validators::Double)
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Skooma
4
+ class Inflector < Zeitwerk::Inflector
5
+ STATIC_MAPPING = {
6
+ "oas_3_1" => "OAS31",
7
+ "openapi" => "OpenAPI",
8
+ "rspec" => "RSpec"
9
+ }
10
+
11
+ def camelize(basename, _abspath)
12
+ if basename.include?("json_")
13
+ super.gsub("Json", "JSON")
14
+ else
15
+ STATIC_MAPPING[basename] || super
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,112 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Skooma
4
+ class Instance < JSONSkooma::JSONNode
5
+ module Coercible
6
+ def coerce(json)
7
+ value = self&.value
8
+ return self if value.nil?
9
+
10
+ case json["type"]
11
+ when "integer"
12
+ begin
13
+ Integer(value, 10)
14
+ rescue ArgumentError
15
+ value
16
+ end
17
+ when "number"
18
+ begin
19
+ Float(value)
20
+ rescue ArgumentError
21
+ value
22
+ end
23
+ when "boolean"
24
+ return true if value == "true"
25
+
26
+ (value == "false") ? false : value
27
+ when "object"
28
+ value
29
+ # convert_object(value, schema)
30
+ when "array"
31
+ # convert_array(value, schema)
32
+ value
33
+ else
34
+ value
35
+ end
36
+ end
37
+ end
38
+
39
+ class Attribute < JSONSkooma::JSONNode
40
+ include Coercible
41
+
42
+ def initialize(value, **item_params)
43
+ super(value, **item_params.merge(item_class: Attribute))
44
+ end
45
+ end
46
+
47
+ class Headers < JSONSkooma::JSONNode
48
+ def [](key)
49
+ super(key.to_s.downcase)
50
+ end
51
+
52
+ private
53
+
54
+ def map_object_value(value)
55
+ value.map { |k, v| [k.to_s.downcase, Attribute.new(v, key: k.to_s, parent: self, **@item_params)] }.to_h
56
+ end
57
+ end
58
+
59
+ class Response < Attribute
60
+ private
61
+
62
+ def parse_value(value)
63
+ data = {}
64
+ data["status"] = JSONSkooma::JSONNode.new(value.fetch("status"), key: "status", parent: self)
65
+ data["headers"] = Headers.new(value.fetch("headers", {}), key: "headers", parent: self)
66
+ body_value = parse_body(value["body"], data["headers"]&.[]("Content-Type"))
67
+ data["body"] = Attribute.new(body_value, key: "body", parent: self)
68
+ ["object", data]
69
+ end
70
+
71
+ def parse_body(body, content_type)
72
+ return nil unless body
73
+
74
+ parser = BodyParsers[content_type&.split(";")&.first]
75
+ parser ? parser.call(body) : body
76
+ end
77
+ end
78
+
79
+ class Request < JSONSkooma::JSONNode
80
+ private
81
+
82
+ def parse_value(value)
83
+ data = {}
84
+ data["query"] = Attribute.new(value.fetch("query", ""), key: "query", parent: self)
85
+ data["headers"] = Headers.new(value.fetch("headers", {}), key: "headers", parent: self)
86
+ body_value = parse_body(value["body"], data["headers"]&.[]("Content-Type"))
87
+ data["body"] = Attribute.new(body_value, key: "body", parent: self)
88
+ ["object", data]
89
+ end
90
+
91
+ def parse_body(body, content_type)
92
+ return nil unless body
93
+
94
+ parser = BodyParsers[content_type&.split(";")&.first]
95
+ parser ? parser.call(body) : body
96
+ end
97
+ end
98
+
99
+ private
100
+
101
+ def parse_value(value)
102
+ data = {
103
+ "method" => JSONSkooma::JSONNode.new(value["method"], key: "method", parent: self),
104
+ "path" => JSONSkooma::JSONNode.new(value["path"], key: "path", parent: self)
105
+ }
106
+ data["request"] = Request.new(value["request"], key: "request", parent: self) if value["request"]
107
+ data["response"] = Response.new(value["response"], key: "response", parent: self) if value["response"]
108
+
109
+ ["object", data]
110
+ end
111
+ end
112
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Skooma
4
+ module Keywords
5
+ module OAS31
6
+ module Dialect
7
+ class Discriminator < JSONSkooma::Keywords::BaseAnnotation
8
+ self.key = "discriminator"
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Skooma
4
+ module Keywords
5
+ module OAS31
6
+ module Dialect
7
+ class Example < JSONSkooma::Keywords::BaseAnnotation
8
+ self.key = "example"
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Skooma
4
+ module Keywords
5
+ module OAS31
6
+ module Dialect
7
+ class ExternalDocs < JSONSkooma::Keywords::BaseAnnotation
8
+ self.key = "externalDocs"
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Skooma
4
+ module Keywords
5
+ module OAS31
6
+ module Dialect
7
+ class Xml < JSONSkooma::Keywords::BaseAnnotation
8
+ self.key = "xml"
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Skooma
4
+ module Keywords
5
+ module OAS31
6
+ class Schema < JSONSkooma::Keywords::Base
7
+ self.key = "schema"
8
+
9
+ def evaluate(instance, result)
10
+ json.evaluate(instance.coerce(json), result)
11
+ end
12
+
13
+ def each_schema
14
+ yield json
15
+ end
16
+
17
+ private
18
+
19
+ def wrap_value(value)
20
+ JSONSkooma::JSONSchema.new(
21
+ value,
22
+ key: key,
23
+ parent: parent_schema,
24
+ registry: parent_schema.registry,
25
+ cache_id: parent_schema.cache_id,
26
+ metaschema_uri: parent_schema.json_schema_dialect_uri
27
+ )
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Skooma
4
+ module Keywords
5
+ module OAS31
6
+ module SchemaValue
7
+ def wrap_value(value)
8
+ return super unless value.is_a?(Hash) || value.is_a?(TrueClass) || value.is_a?(FalseClass)
9
+
10
+ Objects::OpenAPI.new(value, registry: parent_schema.registry, parent: parent_schema, key: key)
11
+ end
12
+
13
+ def each_schema
14
+ return super unless json.is_a?(Objects::OpenAPI)
15
+
16
+ yield json
17
+ end
18
+ end
19
+ JSONSkooma::Keywords::ValueSchemas.register_value_schema(:openapi_schema, SchemaValue)
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Skooma
4
+ module Objects
5
+ class Base
6
+ module Keywords
7
+ class Deprecated < JSONSkooma::Keywords::BaseAnnotation
8
+ self.key = "deprecated"
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Skooma
4
+ module Objects
5
+ class Base
6
+ module Keywords
7
+ class Description < JSONSkooma::Keywords::BaseAnnotation
8
+ self.key = "description"
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Skooma
4
+ module Objects
5
+ class Base
6
+ module Keywords
7
+ class Security < JSONSkooma::Keywords::BaseAnnotation
8
+ self.key = "security"
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Skooma
4
+ module Objects
5
+ class Base
6
+ module Keywords
7
+ class Servers < JSONSkooma::Keywords::BaseAnnotation
8
+ self.key = "servers"
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Skooma
4
+ module Objects
5
+ class Base
6
+ module Keywords
7
+ class Summary < JSONSkooma::Keywords::BaseAnnotation
8
+ self.key = "summary"
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Skooma
4
+ module Objects
5
+ class Base
6
+ module Keywords
7
+ class Tags < JSONSkooma::Keywords::BaseAnnotation
8
+ self.key = "tags"
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Skooma
4
+ module Objects
5
+ class Base < JSONSkooma::JSONSchema
6
+ DEFAULT_OPTIONS = {
7
+ registry: REGISTRY_NAME
8
+ }.freeze
9
+
10
+ def initialize(value, **options)
11
+ super(value, **DEFAULT_OPTIONS.merge(options))
12
+ end
13
+
14
+ def bootstrap(value)
15
+ # nothing to do
16
+ end
17
+
18
+ def kw_classes
19
+ []
20
+ end
21
+
22
+ def json_schema_dialect_uri
23
+ root.json_schema_dialect_uri
24
+ end
25
+
26
+ private
27
+
28
+ def kw_class(k)
29
+ kw_classes.find { |kw| kw.key == k } || JSONSkooma::Keywords::Unknown[k]
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Skooma
4
+ module Objects
5
+ # https://spec.openapis.org/oas/v3.1.0#callback-object
6
+ # A map of possible out-of band callbacks related to the parent operation.
7
+ class Callback < RefBase
8
+ def kw_classes
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Skooma
4
+ module Objects
5
+ # Holds a set of reusable objects for different aspects of the OAS.
6
+ # https://spec.openapis.org/oas/v3.1.0#components-object
7
+ class Components < JSONSkooma::JSONNode
8
+ CLASSES_MAP = {
9
+ "schemas" => JSONSkooma::JSONSchema,
10
+ "responses" => Response,
11
+ "parameters" => Parameter,
12
+ # "examples" => Example,
13
+ "requestBodies" => RequestBody,
14
+ "headers" => Header,
15
+ "securitySchemes" => JSONSkooma::JSONNode,
16
+ "links" => JSONSkooma::JSONNode,
17
+ # "callbacks" => Callback,
18
+ "pathItems" => PathItem
19
+ }
20
+
21
+ def map_object_value(value)
22
+ value.map do |k, v|
23
+ key = k.to_s
24
+ value = JSONSkooma::JSONNode.new(v, key: key, parent: self, item_class: CLASSES_MAP.fetch(key), **@item_params, metaschema_uri: parent.json_schema_dialect_uri)
25
+ [key, value]
26
+ end.to_h
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,50 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Skooma
4
+ module Objects
5
+ class Header
6
+ module Keywords
7
+ class Content < JSONSkooma::Keywords::Base
8
+ self.key = "content"
9
+ self.value_schema = :object_of_schemas
10
+ self.schema_value_class = Objects::MediaType
11
+
12
+ def evaluate(instance, result)
13
+ return if instance&.value.nil?
14
+
15
+ media_type = result.root.instance["response"]["headers"]["Content-Type"]&.split(";")&.first&.strip&.downcase
16
+ media_type_object, matched_media_type = find_media_type(media_type)
17
+
18
+ return result.discard unless media_type_object
19
+
20
+ result.annotate(matched_media_type)
21
+ result.call(instance, matched_media_type) do |media_type_result|
22
+ media_type_object.evaluate(instance, media_type_result)
23
+ result.failure("Invalid content") unless media_type_result.passed?
24
+ end
25
+ end
26
+
27
+ private
28
+
29
+ # The key is a media type or media type range and the value describes it.
30
+ # For requests that match multiple keys, only the most specific key is applicable.
31
+ # e.g. text/plain overrides text/*
32
+ def find_media_type(media_type)
33
+ matched_media_type =
34
+ if json.key?(media_type)
35
+ media_type
36
+ elsif media_type &&
37
+ (key = "#{media_type.split("/").first}/*") &&
38
+ json.key?(key)
39
+ key
40
+ elsif json.key?("*/*")
41
+ "*/*"
42
+ end
43
+
44
+ [json[matched_media_type], matched_media_type]
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Skooma
4
+ module Objects
5
+ class Header
6
+ module Keywords
7
+ class Example < JSONSkooma::Keywords::BaseAnnotation
8
+ self.key = "example"
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Skooma
4
+ module Objects
5
+ class Header
6
+ module Keywords
7
+ class Examples < JSONSkooma::Keywords::BaseAnnotation
8
+ self.key = "examples"
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Skooma
4
+ module Objects
5
+ class Header
6
+ module Keywords
7
+ class Explode < JSONSkooma::Keywords::BaseAnnotation
8
+ self.key = "explode"
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Skooma
4
+ module Objects
5
+ class Header
6
+ module Keywords
7
+ class Required < JSONSkooma::Keywords::Base
8
+ self.key = "required"
9
+
10
+ def evaluate(instance, result)
11
+ if json.value && instance.value.nil?
12
+ result.failure("Header is required")
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Skooma
4
+ module Objects
5
+ class Header
6
+ module Keywords
7
+ class Schema < Skooma::Keywords::OAS31::Schema
8
+ self.key = "schema"
9
+
10
+ def evaluate(instance, result)
11
+ return if instance.value.nil?
12
+
13
+ super
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Skooma
4
+ module Objects
5
+ class Header
6
+ module Keywords
7
+ class Style < JSONSkooma::Keywords::BaseAnnotation
8
+ self.key = "style"
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Skooma
4
+ module Objects
5
+ # https://spec.openapis.org/oas/v3.1.0#header-object
6
+ # The Header Object follows the structure of the Parameter Object.
7
+ class Header < RefBase
8
+ def kw_classes
9
+ [
10
+ Base::Keywords::Description,
11
+ Base::Keywords::Deprecated,
12
+ Keywords::Style,
13
+ Keywords::Explode,
14
+ Keywords::Required,
15
+ Keywords::Schema,
16
+ Keywords::Example,
17
+ Keywords::Examples,
18
+ Keywords::Content
19
+ ]
20
+ end
21
+ end
22
+ end
23
+ end