Joseph Fraley
Joseph Fraley

Reputation: 51

Where can I find the complete specification for AWS SAM Yaml Models?

I have found several official AWS documents that describe some of the structure/schema for specifying models in Yaml files. For example:

In particular, the first document says this at the end:

The examples don't use advanced JSON schema features, such as specifying required items, minimums and maximums (for allowed string lengths, numeric values, and array item lengths), and regular expressions. For more information, see Introducing JSON and JSON schema draft 4.

and links out to https://www.json.org/json-en.html and https://datatracker.ietf.org/doc/html/draft-zyp-json-schema-04

Neither of those documents describe anything about required items, minimums and maximums, or any of these other "advanced" JSON schema features.

Is there some canonical reference that shows what is possible when describing models in a yaml file, and what the syntax is? How does anyone know what to type? For example, when writing a model, how does anyone know that:

        MyModel:
          description: this is an object with one property
          type: object
          properties:
            grade:
              type: integer

is correct. while:

        MyModel:
          description: this is an object with one property
          type: object
          properties:
            grade:
              type: int

is not correct?

Upvotes: 1

Views: 150

Answers (1)

IMSoP
IMSoP

Reputation: 97688

The AWS page is indeed a bit poorly worded. "JSON Schema" is the name of a set of specifications, and "Draft 4" is a particular version of those specifications. (The name "draft" is something of a misnomer, which exists for historic and bureaucratic reasons, so you can read that as "Version 4" or "Release 4".)

The home page for JSON Schema is at https://json-schema.org where you can find the current version of the base specification (which just describes the general format) and the validation specification, which is what you were looking for.

For older versions, you need to look at https://json-schema.org/specification-links.html so if the AWS documentation is correct that API Gateway only supports Draft 4 (from about 10 years ago), the more useful page to link to would have been this: https://datatracker.ietf.org/doc/html/draft-fge-json-schema-validation-00

Upvotes: 1

Related Questions