Forum Discussion

Tempy's avatar
Tempy
Occasional Visitor
3 years ago

empty response in swagger ui

If i try to get student data using the code below in swagger ui i get no data in response

 

 

openapi: "3.0.0"
info: 
  title: Student API
  description: This a Student server for the Aesopia school
  version: 1.0.0
servers:
   - url: http://localhost:3000
paths:
  /student:
    description: Everything about the students 
    get:
      description: Obtain Students information from the database
      parameters:
        - in: query
          name: studentID
          required: true
          schema:
            type: integer
            
      responses: 
        200:
          description: successful 
          content:
           application/json:
            schema:
              $ref: '#/components/schemas/students'
        405:
          description: Invalid input    
    post:
      description: Add new Student to the database
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/student'
      responses:
        201:
          description: Record successfully added

  '/student/{studentId}' :
    get:
      description: Information about specific Student
      parameters:
        - in: path
          name: studentId
          description: Get Student info using student ID filter
          required: true
          schema:
            type: integer
            example: 8
      responses:
        200:
          description: successful
          content:
            application/json:
              schema: 
                $ref: '#/components/schemas/students'
        404:
          description: "Error: Not Found "       
components:
  schemas:
    student:
       description: Model that contains all info about a student
       properties:
        studentID:
          type: integer
          example: 8
        studentname:
          type: string
          example: David Lumo
        studentGrade: 
          type: integer
          example: 80
        email:
          type: string
          example: dlumo@gmail.com
        address: 
          type: string
          example: "24 Mag street"
        town:
          type: string
          example: Midrand
    students:
      description: Array of student info
      type: array
      items:
        properties:
          studentID:
            type: integer
            example: 8
          studentname:
            type: string
            example: David Lumo
          studentGrade: 
            type: integer
            example: 80
          email:
            type: string
            example: dlumo@gmail.com
          address: 
            type: string
            example: "24 Mag street"
          town:
            type: string
            example: Midrand
          
       

 

 

. The below photo shows the response :

this is the student datathis is the response i get 

how can i get data i need

No RepliesBe the first to reply