Class: JSONSchema
protoc_gen_openapiv2.options.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." }]; }
Implements
Constructors
constructor
• new JSONSchema(properties?): JSONSchema
Constructs a new JSONSchema.
Parameters
| Name | Type | Description |
|---|---|---|
properties? | IJSONSchema | Properties to set |
Returns
Properties
array
• array: string[]
Items in 'array' must be unique.
Implementation of
default
• default: string
JSONSchema default.
Implementation of
description
• description: string
A short description of the schema.
Implementation of
enum
• enum: string[]
Items in enum must be unique https://tools.ietf.org/html/draft-fge-json-schema-validation-00#section-5.5.1
Implementation of
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
Implementation of
exclusiveMaximum
• exclusiveMaximum: boolean
JSONSchema exclusiveMaximum.
Implementation of
exclusiveMinimum
• exclusiveMinimum: boolean
JSONSchema exclusiveMinimum.
Implementation of
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]: IValue
Implementation of
fieldConfiguration
• Optional fieldConfiguration: null | IFieldConfiguration
Additional field level properties used when generating the OpenAPI v2 file.
Implementation of
IJSONSchema.fieldConfiguration
format
• format: string
Format
Implementation of
maxItems
• maxItems: Long
JSONSchema maxItems.
Implementation of
maxLength
• maxLength: Long
JSONSchema maxLength.
Implementation of
maxProperties
• maxProperties: Long
JSONSchema maxProperties.
Implementation of
maximum
• maximum: number
Maximum represents an inclusive upper limit for a numeric instance. The value of MUST be a number,
Implementation of
minItems
• minItems: Long
JSONSchema minItems.
Implementation of
minLength
• minLength: Long
JSONSchema minLength.
Implementation of
minProperties
• minProperties: Long
JSONSchema minProperties.
Implementation of
minimum
• minimum: number
minimum represents an inclusive lower limit for a numeric instance. The value of MUST be a number,
Implementation of
multipleOf
• multipleOf: number
JSONSchema multipleOf.
Implementation of
pattern
• pattern: string
JSONSchema pattern.
Implementation of
readOnly
• readOnly: boolean
JSONSchema readOnly.
Implementation of
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".
Implementation of
required
• required: string[]
JSONSchema required.
Implementation of
title
• title: string
The title of the schema.
Implementation of
type
• type: JSONSchemaSimpleTypes[]
JSONSchema type.
Implementation of
uniqueItems
• uniqueItems: boolean
JSONSchema uniqueItems.
Implementation of
Methods
toJSON
▸ toJSON(): Object
Converts this JSONSchema to JSON.
Returns
Object
JSON object
create
▸ create(properties?): JSONSchema
Creates a new JSONSchema instance using the specified properties.
Parameters
| Name | Type | Description |
|---|---|---|
properties? | IJSONSchema | Properties to set |
Returns
JSONSchema instance
decode
▸ decode(reader, length?): JSONSchema
Decodes a JSONSchema message from the specified reader or buffer.
Parameters
| Name | Type | Description |
|---|---|---|
reader | Uint8Array | Reader | Reader or buffer to decode from |
length? | number | Message length if known beforehand |
Returns
JSONSchema
Throws
If the payload is not a reader or valid buffer
Throws
If required fields are missing
decodeDelimited
▸ decodeDelimited(reader): JSONSchema
Decodes a JSONSchema message from the specified reader or buffer, length delimited.
Parameters
| Name | Type | Description |
|---|---|---|
reader | Uint8Array | Reader | Reader or buffer to decode from |
Returns
JSONSchema
Throws
If the payload is not a reader or valid buffer
Throws
If required fields are missing
encode
▸ encode(message, writer?): Writer
Encodes the specified JSONSchema message. Does not implicitly grpc.gateway.protoc_gen_openapiv2.options.JSONSchema.verify|verify messages.
Parameters
| Name | Type | Description |
|---|---|---|
message | IJSONSchema | JSONSchema message or plain object to encode |
writer? | Writer | Writer to encode to |
Returns
Writer
Writer
encodeDelimited
▸ encodeDelimited(message, writer?): Writer
Encodes the specified JSONSchema message, length delimited. Does not implicitly grpc.gateway.protoc_gen_openapiv2.options.JSONSchema.verify|verify messages.
Parameters
| Name | Type | Description |
|---|---|---|
message | IJSONSchema | JSONSchema message or plain object to encode |
writer? | Writer | Writer to encode to |
Returns
Writer
Writer
fromObject
▸ fromObject(object): JSONSchema
Creates a JSONSchema message from a plain object. Also converts values to their respective internal types.
Parameters
| Name | Type | Description |
|---|---|---|
object | Object | Plain object |
Returns
JSONSchema
getTypeUrl
▸ getTypeUrl(typeUrlPrefix?): string
Gets the default type url for JSONSchema
Parameters
| Name | Type | Description |
|---|---|---|
typeUrlPrefix? | string | your custom typeUrlPrefix(default "type.googleapis.com") |
Returns
string
The default type url
toObject
▸ toObject(message, options?): Object
Creates a plain object from a JSONSchema message. Also converts values to other types if specified.
Parameters
| Name | Type | Description |
|---|---|---|
message | JSONSchema | JSONSchema |
options? | IConversionOptions | Conversion options |
Returns
Object
Plain object