Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"type" of a model definition or a response body can either be a string or an array of unique primitive types #1653

Closed
amarzavery opened this issue Dec 2, 2016 · 1 comment

Comments

@amarzavery
Copy link
Contributor

Swagger specification says

The following properties are taken directly from the JSON Schema definition and follow the same specifications:
$ref - As a JSON Reference
format (See Data Type Formats for further details)
title
description (GFM syntax can be used for rich text representation)
default (Unlike JSON Schema, the value MUST conform to the defined type for the Schema Object)
multipleOf
maximum
exclusiveMaximum
minimum
exclusiveMinimum
maxLength
minLength
pattern
maxItems
minItems
uniqueItems
maxProperties
minProperties
required
enum
type <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

This is the definition of type as per the JSON schema draft 4

5.21. type

The value of this keyword MUST be either a string or an array. If it is an array, elements of the array MUST be strings and MUST be unique.

String values MUST be one of the seven primitive types defined by the core specification.

An instance matches successfully if its primitive type is one of the types defined by keyword. Recall: "number" includes "integer".

Primitive types supported by JSON schema.

These are the set of primitives supported by JSON schema.

An instance has one of six primitive types, and a range of possible values depending on the type:

  • null
    A JSON "null" production
  • boolean
    A "true" or "false" value, from the JSON "true" or "false" productions
  • object
    An unordered set of properties mapping a string to an instance, from the JSON "object" production
  • array
    An ordered list of instances, from the JSON "array" production
  • number
    An arbitrary-precision, base-10 decimal number value, from the JSON "number" production
  • string
    A string of Unicode code points, from the JSON "string" production
    Whitespace and formatting concerns are thus outside the scope of JSON Schema.

Since an object cannot have two properties with the same key, behavior for a JSON document that tries to define two properties (the "member" production) with the same key (the "string" production) in a single object is undefined.

So 2 key takeaways for Autorest

  • "null" is a valid primitive type and Autorest should not fail.
  • type can either be a string or an array of unique strings (primitive types)

Currently Autorest fails on both of them.

/cc @johanste @fearthecowboy @veronicagg @markcowl @hovsepm

@johanste
Copy link
Member

johanste commented Dec 5, 2016

Actually, null is not a valid type in Swagger since it is not listed as one of the valid types. Also, the type keyword only supports a single value.

OAI/OpenAPI-Specification#229
OAI/OpenAPI-Specification#458

@johanste johanste closed this as completed Dec 5, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants