diff --git a/lib/rspec/openapi/schema_builder.rb b/lib/rspec/openapi/schema_builder.rb index 45deda77..9b0d4baa 100644 --- a/lib/rspec/openapi/schema_builder.rb +++ b/lib/rspec/openapi/schema_builder.rb @@ -111,7 +111,7 @@ def build_type(value) when ActionDispatch::Http::UploadedFile { type: 'string', format: 'binary' } when NilClass - { type: 'null' } + { nullable: true } else raise NotImplementedError, "type detection is not implemented for: #{value.inspect}" end diff --git a/spec/rails/app/controllers/tables_controller.rb b/spec/rails/app/controllers/tables_controller.rb index 737dbca9..dbe482ea 100644 --- a/spec/rails/app/controllers/tables_controller.rb +++ b/spec/rails/app/controllers/tables_controller.rb @@ -47,6 +47,7 @@ def find_table(id = nil) id: 2, name: 'production', }, + null_sample: nil, storage_size: 12.3, created_at: time.iso8601, updated_at: time.iso8601, diff --git a/spec/rails/doc/openapi.yaml b/spec/rails/doc/openapi.yaml index e62076aa..67634be8 100644 --- a/spec/rails/doc/openapi.yaml +++ b/spec/rails/doc/openapi.yaml @@ -47,6 +47,8 @@ paths: type: integer name: type: string + null_sample: + nullable: true storage_size: type: number format: float @@ -61,6 +63,7 @@ paths: database: id: 2 name: production + null_sample: storage_size: 12.3 created_at: '2020-07-17T00:00:00+00:00' updated_at: '2020-07-17T00:00:00+00:00' @@ -116,6 +119,8 @@ paths: type: integer name: type: string + null_sample: + nullable: true storage_size: type: number format: float @@ -130,6 +135,7 @@ paths: database: id: 2 name: production + null_sample: storage_size: 12.3 created_at: '2020-07-17T00:00:00+00:00' updated_at: '2020-07-17T00:00:00+00:00' @@ -166,6 +172,8 @@ paths: type: integer name: type: string + null_sample: + nullable: true storage_size: type: number format: float @@ -180,6 +188,7 @@ paths: database: id: 2 name: production + null_sample: storage_size: 12.3 created_at: '2020-07-17T00:00:00+00:00' updated_at: '2020-07-17T00:00:00+00:00' @@ -248,6 +257,8 @@ paths: type: integer name: type: string + null_sample: + nullable: true storage_size: type: number format: float @@ -262,6 +273,7 @@ paths: database: id: 2 name: production + null_sample: storage_size: 12.3 created_at: '2020-07-17T00:00:00+00:00' updated_at: '2020-07-17T00:00:00+00:00' @@ -297,6 +309,8 @@ paths: type: integer name: type: string + null_sample: + nullable: true storage_size: type: number format: float @@ -311,6 +325,7 @@ paths: database: id: 2 name: production + null_sample: storage_size: 12.3 created_at: '2020-07-17T00:00:00+00:00' updated_at: '2020-07-17T00:00:00+00:00'