{
  "openapi" : "3.0.1",
  "info" : {
    "title" : "USIC JSON API",
    "description" : "Application Programming Interface for USIC.\r\n  The USIC API adheres to the [{json:api} specification](http://jsonapi.org/) for building APIs in JSON.",
    "contact" : {
      "name" : "Steven Pothoven",
      "email" : "stevenpothoven@usicllc.com"
    },
    "version" : ""
  },
  "servers" : [ {
    "url" : "https://jsonapi-dev.usicllc.com",
    "description" : "Development"
  }, {
    "url" : "https://jsonapi-staging.usicllc.com",
    "description" : "Test"
  }, {
    "url" : "https://jsonapi.usicllc.com",
    "description" : "Production"
  } ],
  "security" : [ {
    "JWT" : [ ]
  } ],
  "tags" : [ {
    "name" : "atomic",
    "description" : "Atomic operations."
  }, {
    "name" : "unauthorized",
    "description" : "operations available without authorization"
  } ],
  "paths" : {
    "/operations" : {
      "post" : {
        "tags" : [ "atomic" ],
        "description" : "Perform atomic operations",
        "requestBody" : {
          "content" : {
            "application/vnd.api+json; ext=\"https://jsonapi.org/ext/atomic\"" : {
              "schema" : {
                "type" : "object",
                "properties" : {
                  "atomic:operations" : {
                    "type" : "array",
                    "items" : {
                      "required" : [ "op" ],
                      "type" : "object",
                      "properties" : {
                        "op" : {
                          "type" : "string",
                          "enum" : [ "add", "update", "remove" ]
                        },
                        "ref" : {
                          "type" : "object",
                          "properties" : {
                            "type" : {
                              "type" : "string"
                            },
                            "id" : {
                              "type" : "string"
                            },
                            "lid" : {
                              "type" : "string"
                            },
                            "relationship" : {
                              "type" : "string"
                            }
                          }
                        },
                        "href" : {
                          "type" : "string"
                        },
                        "data" : {
                          "anyOf" : [ {
                            "type" : "array",
                            "items" : {
                              "type" : "object",
                              "properties" : {
                                "type" : {
                                  "type" : "string"
                                },
                                "id" : {
                                  "type" : "string"
                                },
                                "lid" : {
                                  "type" : "string"
                                },
                                "attributes" : {
                                  "type" : "object"
                                }
                              },
                              "nullable" : true
                            }
                          }, {
                            "type" : "object",
                            "properties" : {
                              "type" : {
                                "type" : "string"
                              },
                              "id" : {
                                "type" : "string"
                              },
                              "lid" : {
                                "type" : "string"
                              },
                              "attributes" : {
                                "type" : "object"
                              }
                            },
                            "nullable" : true
                          } ]
                        },
                        "meta" : {
                          "type" : "object"
                        }
                      },
                      "allOf" : [ {
                        "not" : {
                          "required" : [ "ref", "href" ],
                          "type" : "object"
                        }
                      } ]
                    }
                  }
                }
              },
              "examples" : {
                "Creating Resources" : {
                  "description" : "To create a resource, the operation MUST include an op code of \"add\" as well as a resource object as data. The resource object MUST contain at least a type member. An operation that creates a resource MAY target a resource collection through the operation's href member.",
                  "value" : {
                    "atomic:operations" : [ {
                      "op" : "add",
                      "href" : "/blogPosts",
                      "data" : {
                        "type" : "articles",
                        "attributes" : {
                          "title" : "Title"
                        }
                      }
                    } ]
                  }
                },
                "Updating Resources" : {
                  "description" : "To update a resource, the operation MUST include an op code of \"update\" as well as a resource object as data. An operation that updates a resource MAY target that resource through the operation's ref or href members, but not both.",
                  "value" : {
                    "atomic:operations" : [ {
                      "op" : "update",
                      "data" : {
                        "type" : "articles",
                        "id" : "13",
                        "attributes" : {
                          "title" : "Title"
                        }
                      }
                    } ]
                  }
                },
                "Deleting Resources" : {
                  "description" : "To delete a resource, the operation MUST include an op code of \"remove\". An operation that deletes a resource MUST target that resource through the operation's ref or href members, but not both.",
                  "value" : {
                    "atomic:operations" : [ {
                      "op" : "remove",
                      "ref" : {
                        "type" : "articles",
                        "id" : "13"
                      }
                    } ]
                  }
                },
                "Updating To-One Relationships" : {
                  "description" : "To assign a to-one relationship, the operation MUST include an op code of \"update\" as well as a resource identifier object as data. An operation that updates a resource's to-one relationship MUST target that relationship through the operation's ref or href members, but not both.",
                  "value" : {
                    "atomic:operations" : [ {
                      "op" : "update",
                      "ref" : {
                        "type" : "articles",
                        "id" : "13",
                        "relationship" : "author"
                      },
                      "data" : {
                        "type" : "people",
                        "id" : "9"
                      }
                    } ]
                  }
                },
                "Deleting To-One Relationships" : {
                  "description" : "To clear a to-one relationship, the operation MUST include an op code of \"update\" as well as setting the data to \"null\". An operation that updates a resource's to-one relationship MUST target that relationship through the operation's ref or href members, but not both.",
                  "value" : {
                    "atomic:operations" : [ {
                      "op" : "update",
                      "ref" : {
                        "type" : "articles",
                        "id" : "13",
                        "relationship" : "author"
                      },
                      "data" : null
                    } ]
                  }
                },
                "Creating To-Many Relationships" : {
                  "description" : "To add members to a to-many relationship, the operation MUST include an op code of \"add\" as well as an array of resource identifier objects as data. An operation that updates a resource's to-many relationship MUST target that relationship through the operation's ref or href members, but not both.",
                  "value" : {
                    "atomic:operations" : [ {
                      "op" : "add",
                      "ref" : {
                        "type" : "articles",
                        "id" : "1",
                        "relationship" : "comments"
                      },
                      "data" : [ {
                        "type" : "comments",
                        "id" : "1"
                      } ]
                    } ]
                  }
                },
                "Updating To-Many Relationships" : {
                  "description" : "To replace all the members of a to-many relationship, the operation MUST include an op code of \"update\" as well as an array of resource identifier objects as data. An operation that updates a resource's to-many relationship MUST target that relationship through the operation's ref or href members, but not both.",
                  "value" : {
                    "atomic:operations" : [ {
                      "op" : "update",
                      "ref" : {
                        "type" : "articles",
                        "id" : "1",
                        "relationship" : "tags"
                      },
                      "data" : [ {
                        "type" : "tags",
                        "id" : "2"
                      }, {
                        "type" : "tags",
                        "id" : "3"
                      } ]
                    } ]
                  }
                },
                "Deleting To-Many Relationships" : {
                  "description" : "To remove members from a to-many relationship, the operation MUST include an op code of \"remove\" as well as an array of resource identifier objects as data. An operation that updates a resource's to-many relationship MUST target that relationship through the operation's ref or href members, but not both.",
                  "value" : {
                    "atomic:operations" : [ {
                      "op" : "remove",
                      "ref" : {
                        "type" : "articles",
                        "id" : "1",
                        "relationship" : "comments"
                      },
                      "data" : [ {
                        "type" : "comments",
                        "id" : "12"
                      }, {
                        "type" : "comments",
                        "id" : "13"
                      } ]
                    } ]
                  }
                }
              }
            }
          }
        },
        "responses" : {
          "200" : {
            "description" : "Successful response",
            "content" : {
              "application/vnd.api+json; ext=\"https://jsonapi.org/ext/atomic\"" : {
                "schema" : {
                  "type" : "object",
                  "properties" : {
                    "atomic:results" : {
                      "type" : "array",
                      "items" : {
                        "type" : "object",
                        "properties" : {
                          "data" : {
                            "type" : "object",
                            "properties" : {
                              "link" : {
                                "type" : "object"
                              },
                              "type" : {
                                "type" : "string"
                              },
                              "id" : {
                                "type" : "string"
                              },
                              "attributes" : {
                                "type" : "object"
                              }
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400" : {
            "description" : "Bad request",
            "content" : {
              "application/vnd.api+json; ext=\"https://jsonapi.org/ext/atomic\"" : {
                "schema" : {
                  "type" : "array",
                  "items" : {
                    "type" : "object",
                    "properties" : {
                      "id" : {
                        "type" : "string"
                      },
                      "links" : {
                        "type" : "object",
                        "properties" : {
                          "about" : {
                            "type" : "string"
                          },
                          "type" : {
                            "type" : "string"
                          }
                        }
                      },
                      "status" : {
                        "type" : "string"
                      },
                      "code" : {
                        "type" : "string"
                      },
                      "title" : {
                        "type" : "string"
                      },
                      "detail" : {
                        "type" : "string"
                      },
                      "source" : {
                        "type" : "object",
                        "properties" : {
                          "pointer" : {
                            "type" : "string"
                          },
                          "parameter" : {
                            "type" : "string"
                          },
                          "header" : {
                            "type" : "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "423" : {
            "description" : "Locked",
            "content" : {
              "application/vnd.api+json; ext=\"https://jsonapi.org/ext/atomic\"" : {
                "schema" : {
                  "type" : "array",
                  "items" : {
                    "type" : "object",
                    "properties" : {
                      "id" : {
                        "type" : "string"
                      },
                      "links" : {
                        "type" : "object",
                        "properties" : {
                          "about" : {
                            "type" : "string"
                          },
                          "type" : {
                            "type" : "string"
                          }
                        }
                      },
                      "status" : {
                        "type" : "string"
                      },
                      "code" : {
                        "type" : "string"
                      },
                      "title" : {
                        "type" : "string"
                      },
                      "detail" : {
                        "type" : "string"
                      },
                      "source" : {
                        "type" : "object",
                        "properties" : {
                          "pointer" : {
                            "type" : "string"
                          },
                          "parameter" : {
                            "type" : "string"
                          },
                          "header" : {
                            "type" : "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/auth" : {
      "post" : {
        "tags" : [ "unauthorized" ],
        "description" : "Login to the API",
        "requestBody" : {
          "content" : {
            "application/json" : {
              "schema" : {
                "required" : [ "password", "username" ],
                "type" : "object",
                "properties" : {
                  "username" : {
                    "type" : "string",
                    "example" : "username@usicllc.com"
                  },
                  "password" : {
                    "type" : "string",
                    "format" : "password",
                    "example" : "secret"
                  }
                }
              }
            }
          }
        },
        "responses" : {
          "200" : {
            "description" : "OK",
            "content" : {
              "application/json" : {
                "schema" : {
                  "required" : [ "token" ],
                  "type" : "object",
                  "properties" : {
                    "token" : {
                      "type" : "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components" : {
    "securitySchemes" : {
      "JWT" : {
        "type" : "http",
        "description" : "Provide JWT token returned from `/auth`",
        "name" : "Authorization",
        "in" : "header",
        "scheme" : "bearer",
        "bearerFormat" : "JWT"
      }
    }
  }
}