QuestionQ46

VerifiedDesigning APIs and Connectivity

Refer to the exhibit. This RAML fragment specifies a Book data type that is used in a RAML API specification.

An API implementation is created for this RAML API specification. What is valid JSON input for a request from a web client to an implementation of this RAML API specification?

Question Image

Explanation

In RAML 1.0, object properties are required by default; a trailing ? in a property declaration (here ID? and publisher?) marks that property as optional. A valid Book instance must therefore supply title (string), author (string), year (integer), and the explicitly required ISBN (string). A JSON object containing exactly ISBN, year, title, and author with correctly typed values satisfies the type. The ? suffix is declaration syntax only — the actual JSON keys for the optional properties are ID and publisher, so keys written literally as "ID?" or "publisher?" do not match those declarations, and objects that omit required properties or contain malformed syntax (missing commas, unkeyed nested objects) are not valid input.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!