Bird
0
0

Which of the following is the correct way to specify a GET operation for the path /pets in OpenAPI YAML?

easy📝 Syntax Q3 of 15
Rest API - API Documentation
Which of the following is the correct way to specify a GET operation for the path /pets in OpenAPI YAML?
Apaths:\n get:\n /pets:\n summary: List all pets
Bget:\n paths:\n /pets:\n summary: List all pets
Cpaths:\n /pets:\n get:\n summary: List all pets
Dpaths:\n /pets:\n method: GET\n summary: List all pets
Step-by-Step Solution
Solution:
  1. Step 1: Review OpenAPI YAML structure for operations

    The correct structure places the path under paths, then the HTTP method (like get) as a nested key, followed by operation details.
  2. Step 2: Check each option's syntax

    paths:\n /pets:\n get:\n summary: List all pets correctly nests get under /pets inside paths. Others misplace keys or use invalid keywords like method.
  3. Final Answer:

    paths:\n /pets:\n get:\n summary: List all pets -> Option C
  4. Quick Check:

    Correct YAML nesting = paths:\n /pets:\n get:\n summary: List all pets [OK]
Quick Trick: HTTP methods go under paths, not above [OK]
Common Mistakes:
MISTAKES
  • Placing method before path
  • Using 'method' instead of HTTP verb
  • Incorrect YAML indentation

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes