Bird
0
0

Which OpenAPI feature helps you define the optional category filter parameter for the GET /products endpoint?

hard📝 Application Q15 of 15
Rest API - API Documentation
You want to document an API that returns a list of products with optional filtering by category. Which OpenAPI feature helps you define the optional category filter parameter for the GET /products endpoint?
AUse a query parameter with <code>required: false</code> under the GET method
BAdd a path parameter named <code>category</code> in the URL
CInclude <code>category</code> in the requestBody schema
DDefine <code>category</code> as a header parameter
Step-by-Step Solution
Solution:
  1. Step 1: Understand parameter types

    Optional filters are usually query parameters, not path or header parameters.
  2. Step 2: Define optional query parameter

    Set required: false for the category query parameter under GET.
  3. Final Answer:

    Use a query parameter with required: false under the GET method -> Option A
  4. Quick Check:

    Optional filters = query params with required false [OK]
Quick Trick: Filters usually go as optional query parameters [OK]
Common Mistakes:
MISTAKES
  • Using path parameters for optional filters
  • Putting filters in requestBody for GET
  • Defining filters as headers

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes