Class: JSONSchema
JSONSchema represents properties from JSON Schema taken, and as used, in
the OpenAPI v2 spec.
This includes changes made by OpenAPI v2.
See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#schemaObject
See also: https://cswr.github.io/JsonSchema/spec/basic_types/, https://github.com/json-schema-org/json-schema-spec/blob/master/schema.json
Example:
message SimpleMessage { option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_schema) = { json_schema: { title: "SimpleMessage" description: "A simple message." required: ["id"] } };
// Id represents the message identifier. string id = 1; [ (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = { description: "The unique identifier of the simple message." }]; }
Properties
array
array:
string[]
Items in 'array' must be unique.
default
default:
string
JSONSchema default.
description
description:
string
A short description of the schema.
enum
enum:
string[]
Items in enum must be unique https://tools.ietf.org/html/draft-fge-json-schema-validation-00#section-5.5.1
example
example:
string
A free-form property to include a JSON example of this field. This is copied verbatim to the output swagger.json. Quotes must be escaped. This property is the same for 2.0 and 3.0.0 https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/3.0.0.md#schemaObject https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#schemaObject
exclusiveMaximum
exclusiveMaximum:
boolean
JSONSchema exclusiveMaximum.
exclusiveMinimum
exclusiveMinimum:
boolean
JSONSchema exclusiveMinimum.
extensions
extensions:
object
Custom properties that start with "x-" such as "x-foo" used to describe extra functionality that is not covered by the standard OpenAPI Specification. See: https://swagger.io/docs/specification/2-0/swagger-extensions/
Index Signature
[k: string]: $Properties
fieldConfiguration?
optionalfieldConfiguration?:$Properties|null
Additional field level properties used when generating the OpenAPI v2 file.
format
format:
string
Format
maximum
maximum:
number
Maximum represents an inclusive upper limit for a numeric instance. The value of MUST be a number,
maxItems
maxItems:
Long
JSONSchema maxItems.
maxLength
maxLength:
Long
JSONSchema maxLength.
maxProperties
maxProperties:
Long
JSONSchema maxProperties.
minimum
minimum:
number
minimum represents an inclusive lower limit for a numeric instance. The value of MUST be a number,
minItems
minItems:
Long
JSONSchema minItems.
minLength
minLength:
Long
JSONSchema minLength.
minProperties
minProperties:
Long
JSONSchema minProperties.
multipleOf
multipleOf:
number
JSONSchema multipleOf.
pattern
pattern:
string
JSONSchema pattern.
readOnly
readOnly:
boolean
JSONSchema readOnly.
ref
ref:
string
Ref is used to define an external reference to include in the message.
This could be a fully qualified proto message reference, and that type must
be imported into the protofile. If no message is identified, the Ref will
be used verbatim in the output.
For example:
ref: ".google.protobuf.Timestamp".
required
required:
string[]
JSONSchema required.
title
title:
string
The title of the schema.
type
type:
JSONSchemaSimpleTypes[]
JSONSchema type.
uniqueItems
uniqueItems:
boolean
JSONSchema uniqueItems.
Methods
toJSON()
toJSON():
object
Converts this JSONSchema to JSON.
Returns
object
JSON object
create()
Call Signature
staticcreate(properties?):JSONSchema&$Shape
Creates a new JSONSchema instance using the specified properties.
Parameters
properties?
Properties to set
Returns
JSONSchema & $Shape
JSONSchema instance
Call Signature
staticcreate(properties?):JSONSchema
Creates a new JSONSchema instance using the specified properties.
Parameters
properties?
Properties to set
Returns
JSONSchema
JSONSchema instance
decode()
staticdecode(reader,length?):JSONSchema&$Shape
Decodes a JSONSchema message from the specified reader or buffer.
Parameters
reader
Uint8Array<ArrayBufferLike> | Reader
Reader or buffer to decode from
length?
number
Message length if known beforehand
Returns
JSONSchema & $Shape
JSONSchema
Throws
If the payload is not a reader or valid buffer
Throws
If required fields are missing
decodeDelimited()
staticdecodeDelimited(reader):JSONSchema&$Shape
Decodes a JSONSchema message from the specified reader or buffer, length delimited.
Parameters
reader
Uint8Array<ArrayBufferLike> | Reader
Reader or buffer to decode from
Returns
JSONSchema & $Shape
JSONSchema
Throws
If the payload is not a reader or valid buffer
Throws
If required fields are missing
encode()
staticencode(message,writer?):Writer
Encodes the specified JSONSchema message. Does not implicitly grpc.gateway.protoc_gen_openapiv2.options.JSONSchema.verify|verify messages.
Parameters
message
JSONSchema message or plain object to encode
writer?
Writer
Writer to encode to
Returns
Writer
Writer
encodeDelimited()
staticencodeDelimited(message,writer?):Writer
Encodes the specified JSONSchema message, length delimited. Does not implicitly grpc.gateway.protoc_gen_openapiv2.options.JSONSchema.verify|verify messages.
Parameters
message
JSONSchema message or plain object to encode
writer?
Writer
Writer to encode to
Returns
Writer
Writer
fromObject()
staticfromObject(object):JSONSchema
Creates a JSONSchema message from a plain object. Also converts values to their respective internal types.
Parameters
object
{[k: string]: any; }
Plain object
Returns
JSONSchema
JSONSchema
toObject()
statictoObject(message,options?):object
Creates a plain object from a JSONSchema message. Also converts values to other types if specified.
Parameters
message
JSONSchema
JSONSchema
options?
IConversionOptions
Conversion options
Returns
object
Plain object