DevNet Associate (DEVASC) v1.0Understanding and Using APIsMedium

A developer is documenting a new internal REST API using OpenAPI Specification (OAS). The API has an endpoint `/api/v1/devices/{deviceId}` that supports a `GET` operation to retrieve device details and a `PUT` operation to update device details. Which OpenAPI component would be used to define the structure of the `deviceId` in the URL path for both operations?

  1. AParameters
  2. BResponses
  3. CSecurity Schemes
  4. DSchemas
Show answer & explanation

Correct answer: A. Parameters

In OpenAPI Specification, path variables like `{deviceId}` are defined as `parameters`. These parameters specify their name, location (path, query, header, cookie), type, and description.

Why the other options are wrong

  • B. Responses define the structure of the HTTP response messages for different status codes.
  • C. Security Schemes define the authentication methods used by the API (e.g., API keys, OAuth2).
  • D. Schemas define the structure of request bodies, response bodies, or complex objects, not path variables.

OpenAPI Parameters

In OpenAPI Specification, parameters define the inputs to an API operation, such as path variables, query strings, headers, or cookies.

  • Defined with `name`, `in` (path, query, header, cookie), `schema`, and `description`.
  • Path parameters (`in: path`) are essential for dynamic URLs.
  • Describe how clients should send specific data to the API.

Memory trick: OpenAPI: Paths Have Parameters, Responses Use Schemas, Security Protects.

More Understanding and Using APIs questions