{
  "swagger": "2.0",
  "info": {
    "version": "1.0.0",
    "title": "Modular Design API's",
    "description": "API for modular design project"
  },
  "paths": {
    "/api/user": {
      "post": {
        "tags": ["Users"],
        "summary": "User Signup",
        "parameters": [
          {
            "name": "user_info",
            "in": "body",
            "required": true,
            "schema": {
              "$ref": "#/definitions/UserSignupDetails"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "User created successfully",
            "schema": {
              "$ref": "#/definitions/UserSignedIn"
            }
          },
          "400": {
            "description": "Bad request"
          }
        }
      },
      "get": {
        "tags": ["Users"],
        "summary": "Authenticate user",
        "parameters": [
          {
            "name": "user_info",
            "in": "body",
            "required": true,
            "schema": {
              "$ref": "#/definitions/UserLoginDetails"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "User Authentictaed  successfully",

            "schema": {
              "$ref": "#/definitions/UserSignedIn"
            }
          },
          "400": {
            "description": "Bad request"
          }
        }
      }
    },

    "/api/user/{userId}": {
      "put": {
        "tags": ["Users"],
        "summary": "Update a user's information",
        "parameters": [
          {
            "name": "projectId",
            "in": "path",
            "description": "User ID to update relevant user info",
            "required": true,
            "type": "integer"
          },
          {
            "name": "updated_user_info",
            "in": "body",
            "required": true,
            "schema": {
              "$ref": "#/definitions/UserSignedIn"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "User Info updated successfully",
            "schema": {
              "$ref": "#/definitions/UserSignedIn"
            }
          },
          "400": {
            "description": "Bad request"
          }
        }
      }
    },

    "/api/projects": {
      "post": {
        "tags": ["Projects"],
        "summary": "Add a New Project",
        "parameters": [
          {
            "name": "project-name",
            "in": "body",
            "description": "Project description",
            "required": true,
            "schema": {
              "$ref": "#/definitions/Project"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Project created successfully",
            "schema": {
              "$ref": "#/definitions/Project"
            }
          },
          "400": {
            "description": "Bad request"
          }
        }
      },
      "get": {
        "tags": ["Projects"],
        "summary": "List all projects",
        "responses": {
          "200": {
            "description": "List of projects",
            "schema": {
              "type": "array",
              "items": {
                "$ref": "#/definitions/Project"
              }
            }
          }
        }
      }
    },
    "/api/projects/{projectId}": {
      "put": {
        "tags": ["Projects"],
        "summary": "Update a project",
        "parameters": [
          {
            "name": "project-name",
            "in": "body",
            "description": "Project description",
            "required": true,
            "schema": {
              "$ref": "#/definitions/Project"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Project updated successfully",
            "schema": {
              "type": "array",
              "items": {
                "$ref": "#/definitions/Project"
              }
            }
          },
          "404": {
            "description": "Project not found"
          }
        }
      },

      "get": {
        "tags": ["Projects"],
        "summary": "fetch a project's data",
        "parameters": [
          {
            "name": "projectId",
            "in": "path",
            "description": "ID of the project to be fetched",
            "required": true,
            "type": "integer"
          }
        ],
        "responses": {
          "200": {
            "description": "project data",
            "schema": {
              "type": "array",
              "items": {
                "type": "object",
                "$ref": "#/definitions/Project"
              }
            }
          }
        }
      },

      "delete": {
        "tags": ["Projects"],
        "summary": "Delete a project by ID",
        "parameters": [
          {
            "name": "projectId",
            "in": "path",
            "description": "ID of the project to be deleted",
            "required": true,
            "type": "integer"
          }
        ],
        "responses": {
          "204": {
            "description": "Project deleted successfully"
          },
          "404": {
            "description": "Project not found"
          }
        }
      }
    },

    "/api/segments": {
      "post": {
        "tags": ["Segments"],
        "summary": "Add a new segment into project",
        "parameters": [
          {
            "name": "segment_details",
            "in": "body",
            "description": "Segment Initial Information",
            "required": true,
            "schema": {
              "$ref": "#/definitions/Segment"
            }
          },
          {
            "name": "segment_data",
            "in": "body",
            "description": "Segment Data",
            "required": true,
            "schema": {
              "$ref": "#/definitions/SegmentDetail"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Segment created successfully",
            "schema": {
              "$ref": "#/definitions/Segment"
            }
          },
          "400": {
            "description": "Bad request"
          }
        }
      },

      "get": {
        "tags": ["Segments"],
        "summary": "List all segments of a project",
        "parameters": [
          {
            "name": "projectId",
            "in": "path",
            "description": "ID of the project to be fetched",
            "required": true,
            "type": "integer"
          }
        ],
        "responses": {
          "200": {
            "description": "List all segments of a project",
            "schema": {
              "type": "array",
              "items": {
                "type": "object",
                "$ref": "#/definitions/Project"
              }
            }
          }
        }
      }
    },

    "/api/segments/{segmentId}": {
      "put": {
        "tags": ["Segments"],
        "summary": "Update segment of a project",
        "parameters": [
          {
            "name": "segment_details",
            "in": "body",
            "description": "Segment  Information",
            "required": true,
            "schema": {
              "$ref": "#/definitions/Segment"
            }
          },
          {
            "name": "segment_data",
            "in": "body",
            "description": "Segment Data",
            "required": true,
            "schema": {
              "$ref": "#/definitions/SegmentDetail"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Segment created successfully",
            "schema": {
              "$ref": "#/definitions/Segment"
            }
          },
          "400": {
            "description": "Bad request"
          }
        }
      },
      "get": {
        "tags": ["Segments"],
        "summary": "fetch a segment of a project",
        "parameters": [
          {
            "name": "segmentId",
            "in": "path",
            "description": "ID of the segment to be fetched",
            "required": true,
            "type": "integer"
          }
        ],
        "responses": {
          "200": {
            "description": "fetch a segments of a project",
            "schema": {
              "type": "object"
            }
          }
        }
      },
      "delete": {
        "tags": ["Segments"],
        "summary": "Delete a segment by ID",
        "parameters": [
          {
            "name": "segmentId",
            "in": "path",
            "description": "ID of the segment to be deleted",
            "required": true,
            "type": "integer"
          }
        ],
        "responses": {
          "204": {
            "description": "Segment deleted successfully"
          },
          "404": {
            "description": "Segment not found"
          }
        }
      }
    },

    "/api/mrs-years": {
      "get": {
        "tags": ["MRS Years"],
        "summary": "Get all MRS Years",
        "responses": {
          "200": {
            "description": "On Success List all MRS years ",
            "schema": {
              "type": "object"
            }
          }
        }
      }
    },
    "/api/locations": {
      "get": {
        "tags": ["Locations"],
        "summary": "Get all Locations",
        "responses": {
          "200": {
            "description": "On Success List all Locations names ",
            "schema": {
              "type": "object"
            }
          }
        }
      }
    }
  },

  "definitions": {
    "Project": {
      "type": "object",
      "properties": {
        "name": {
          "type": "string"
        },
        "location": {
          "type": "string"
        },
        "psdp_or_apd_no": {
          "type": "string"
        },
        "road_length": {
          "type": "number"
        },
        "mrs_year": {
          "type": "string"
        }
      }
    },

    "SegmentDetail": {
      "properties": {
        "segment_data": {
          "type": "object"
        }
      }
    },

    "Segment": {
      "type": "object",
      "properties": {
        "project_id": {
          "type": "string"
        },
        "name": {
          "type": "string"
        },
        "from_road": {
          "type": "string"
        },
        "to_road": {
          "type": "string"
        },
        "type": {
          "type": "string"
        }
      }
    },

    "SegmentTypes": {
      "enum": [
        "Road Section",
        "T-Bridge",
        "Slab Bridge",
        "Box Culvert",
        "Counterfort Reataining Wall",
        "Cantilever Reataining Wall",
        "Gravity RetainigWall Sloping Inward",
        "Gravity RetainigWall Sloping Outward",
        "Closed Causeway",
        "Vented Causeway"
      ],
      "type": "string"
    },

    "locations": {
      "enum": [
        "Abbottabad",
        "Bannu",
        "Battagram",
        "Buner",
        "Charsadda",
        "Chitral",
        "Dera Ismail Khan",
        "Hangu",
        "Haripur",
        "Karak",
        "Kohat",
        "Kohistan",
        "Lakki Marwat",
        "Lower Dir",
        "Malakand",
        "Mansehra",
        "Mardan",
        "Nowshera",
        "Peshawar",
        "Shangla",
        "Swabi",
        "Swat",
        "Tank",
        "Upper Dir"
      ],
      "type": "string"
    },
    "UserSignupDetails": {
      "type": "object",
      "properties": {
        "name": { "type": "string" },
        "email": { "type": "string" },
        "mrs_year": { "type": "string" },
        "pec_number": { "type": "number" },
        "organisation": { "type": "string" },
        "city": { "type": "string" },
        "password": { "type": "string" }
      }
    },
    "UserLoginDetails": {
      "type": "object",
      "properties": {
        "email": { "type": "string" },
        "password": { "type": "string" }
      }
    },
    "UserSignedIn": {
      "type": "object",
      "properties": {
        "name": { "type": "string" },
        "email": { "type": "string" },
        "mrs_year": { "type": "string" },
        "pec_number": { "type": "number" },
        "organisation": { "type": "string" },
        "city": { "type": "string" }
      }
    }
  }
  
}
