mirror of
				https://github.com/NginxProxyManager/nginx-proxy-manager.git
				synced 2025-10-31 15:53:33 +00:00 
			
		
		
		
	Refactor API Schema and validation
- /schema now returns full openapi/swagger schema - That schema is used to validate incoming requests - And used as a contract in future integration tests - Moved route files up one level - Fixed incorrect 404 reponses when getting objects - Fixed saving new objects and passing jsonschemavalidation
This commit is contained in:
		
							
								
								
									
										39
									
								
								backend/schema/paths/nginx/dead-hosts/hostID/delete.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								backend/schema/paths/nginx/dead-hosts/hostID/delete.json
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,39 @@ | ||||
| { | ||||
| 	"operationId": "deleteDeadHost", | ||||
| 	"summary": "Delete a 404 Host", | ||||
| 	"tags": ["404 Hosts"], | ||||
| 	"security": [ | ||||
| 		{ | ||||
| 			"BearerAuth": ["dead_hosts"] | ||||
| 		} | ||||
| 	], | ||||
| 	"parameters": [ | ||||
| 		{ | ||||
| 			"in": "path", | ||||
| 			"name": "hostID", | ||||
| 			"schema": { | ||||
| 				"type": "integer", | ||||
| 				"minimum": 1 | ||||
| 			}, | ||||
| 			"required": true, | ||||
| 			"example": 2 | ||||
| 		} | ||||
| 	], | ||||
| 	"responses": { | ||||
| 		"200": { | ||||
| 			"description": "200 response", | ||||
| 			"content": { | ||||
| 				"application/json": { | ||||
| 					"examples": { | ||||
| 						"default": { | ||||
| 							"value": true | ||||
| 						} | ||||
| 					}, | ||||
| 					"schema": { | ||||
| 						"type": "boolean" | ||||
| 					} | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
| @@ -0,0 +1,59 @@ | ||||
| { | ||||
| 	"operationId": "disableDeadHost", | ||||
| 	"summary": "Disable a 404 Host", | ||||
| 	"tags": ["404 Hosts"], | ||||
| 	"security": [ | ||||
| 		{ | ||||
| 			"BearerAuth": ["dead_hosts"] | ||||
| 		} | ||||
| 	], | ||||
| 	"parameters": [ | ||||
| 		{ | ||||
| 			"in": "path", | ||||
| 			"name": "hostID", | ||||
| 			"schema": { | ||||
| 				"type": "integer", | ||||
| 				"minimum": 1 | ||||
| 			}, | ||||
| 			"required": true, | ||||
| 			"example": 2 | ||||
| 		} | ||||
| 	], | ||||
| 	"responses": { | ||||
| 		"200": { | ||||
| 			"description": "200 response", | ||||
| 			"content": { | ||||
| 				"application/json": { | ||||
| 					"examples": { | ||||
| 						"default": { | ||||
| 							"value": true | ||||
| 						} | ||||
| 					}, | ||||
| 					"schema": { | ||||
| 						"type": "boolean" | ||||
| 					} | ||||
| 				} | ||||
| 			} | ||||
| 		}, | ||||
| 		"400": { | ||||
| 			"description": "400 response", | ||||
| 			"content": { | ||||
| 				"application/json": { | ||||
| 					"examples": { | ||||
| 						"default": { | ||||
| 							"value": { | ||||
| 								"error": { | ||||
| 									"code": 400, | ||||
| 									"message": "Host is already disabled" | ||||
| 								} | ||||
| 							} | ||||
| 						} | ||||
| 					}, | ||||
| 					"schema": { | ||||
| 						"$ref": "../../../../../components/error-object.json" | ||||
| 					} | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
| @@ -0,0 +1,59 @@ | ||||
| { | ||||
| 	"operationId": "enableDeadHost", | ||||
| 	"summary": "Enable a 404 Host", | ||||
| 	"tags": ["404 Hosts"], | ||||
| 	"security": [ | ||||
| 		{ | ||||
| 			"BearerAuth": ["dead_hosts"] | ||||
| 		} | ||||
| 	], | ||||
| 	"parameters": [ | ||||
| 		{ | ||||
| 			"in": "path", | ||||
| 			"name": "hostID", | ||||
| 			"schema": { | ||||
| 				"type": "integer", | ||||
| 				"minimum": 1 | ||||
| 			}, | ||||
| 			"required": true, | ||||
| 			"example": 2 | ||||
| 		} | ||||
| 	], | ||||
| 	"responses": { | ||||
| 		"200": { | ||||
| 			"description": "200 response", | ||||
| 			"content": { | ||||
| 				"application/json": { | ||||
| 					"examples": { | ||||
| 						"default": { | ||||
| 							"value": true | ||||
| 						} | ||||
| 					}, | ||||
| 					"schema": { | ||||
| 						"type": "boolean" | ||||
| 					} | ||||
| 				} | ||||
| 			} | ||||
| 		}, | ||||
| 		"400": { | ||||
| 			"description": "400 response", | ||||
| 			"content": { | ||||
| 				"application/json": { | ||||
| 					"examples": { | ||||
| 						"default": { | ||||
| 							"value": { | ||||
| 								"error": { | ||||
| 									"code": 400, | ||||
| 									"message": "Host is already enabled" | ||||
| 								} | ||||
| 							} | ||||
| 						} | ||||
| 					}, | ||||
| 					"schema": { | ||||
| 						"$ref": "../../../../../components/error-object.json" | ||||
| 					} | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
							
								
								
									
										56
									
								
								backend/schema/paths/nginx/dead-hosts/hostID/get.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										56
									
								
								backend/schema/paths/nginx/dead-hosts/hostID/get.json
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,56 @@ | ||||
| { | ||||
| 	"operationId": "getDeadHost", | ||||
| 	"summary": "Get a 404 Host", | ||||
| 	"tags": ["404 Hosts"], | ||||
| 	"security": [ | ||||
| 		{ | ||||
| 			"BearerAuth": ["dead_hosts"] | ||||
| 		} | ||||
| 	], | ||||
| 	"parameters": [ | ||||
| 		{ | ||||
| 			"in": "path", | ||||
| 			"name": "hostID", | ||||
| 			"schema": { | ||||
| 				"type": "integer", | ||||
| 				"minimum": 1 | ||||
| 			}, | ||||
| 			"required": true, | ||||
| 			"example": 1 | ||||
| 		} | ||||
| 	], | ||||
| 	"responses": { | ||||
| 		"200": { | ||||
| 			"description": "200 response", | ||||
| 			"content": { | ||||
| 				"application/json": { | ||||
| 					"examples": { | ||||
| 						"default": { | ||||
| 							"value": { | ||||
| 								"id": 1, | ||||
| 								"created_on": "2024-10-09T01:38:52.000Z", | ||||
| 								"modified_on": "2024-10-09T01:38:52.000Z", | ||||
| 								"owner_user_id": 1, | ||||
| 								"domain_names": ["test.example.com"], | ||||
| 								"certificate_id": 0, | ||||
| 								"ssl_forced": 0, | ||||
| 								"advanced_config": "", | ||||
| 								"meta": { | ||||
| 									"nginx_online": true, | ||||
| 									"nginx_err": null | ||||
| 								}, | ||||
| 								"http2_support": 0, | ||||
| 								"enabled": 1, | ||||
| 								"hsts_enabled": 0, | ||||
| 								"hsts_subdomains": 0 | ||||
| 							} | ||||
| 						} | ||||
| 					}, | ||||
| 					"schema": { | ||||
| 						"$ref": "../../../../components/dead-host-object.json" | ||||
| 					} | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
							
								
								
									
										110
									
								
								backend/schema/paths/nginx/dead-hosts/hostID/put.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										110
									
								
								backend/schema/paths/nginx/dead-hosts/hostID/put.json
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,110 @@ | ||||
| { | ||||
| 	"operationId": "updateDeadHost", | ||||
| 	"summary": "Update a 404 Host", | ||||
| 	"tags": ["404 Hosts"], | ||||
| 	"security": [ | ||||
| 		{ | ||||
| 			"BearerAuth": ["dead_hosts"] | ||||
| 		} | ||||
| 	], | ||||
| 	"parameters": [ | ||||
| 		{ | ||||
| 			"in": "path", | ||||
| 			"name": "hostID", | ||||
| 			"schema": { | ||||
| 				"type": "integer", | ||||
| 				"minimum": 1 | ||||
| 			}, | ||||
| 			"required": true, | ||||
| 			"example": 2 | ||||
| 		} | ||||
| 	], | ||||
| 	"requestBody": { | ||||
| 		"description": "404 Host Payload", | ||||
| 		"required": true, | ||||
| 		"content": { | ||||
| 			"application/json": { | ||||
| 				"schema": { | ||||
| 					"type": "object", | ||||
| 					"additionalProperties": false, | ||||
| 					"minProperties": 1, | ||||
| 					"properties": { | ||||
| 						"domain_names": { | ||||
| 							"$ref": "../../../../components/dead-host-object.json#/properties/domain_names" | ||||
| 						}, | ||||
| 						"certificate_id": { | ||||
| 							"$ref": "../../../../components/dead-host-object.json#/properties/certificate_id" | ||||
| 						}, | ||||
| 						"ssl_forced": { | ||||
| 							"$ref": "../../../../components/dead-host-object.json#/properties/ssl_forced" | ||||
| 						}, | ||||
| 						"hsts_enabled": { | ||||
| 							"$ref": "../../../../components/dead-host-object.json#/properties/hsts_enabled" | ||||
| 						}, | ||||
| 						"hsts_subdomains": { | ||||
| 							"$ref": "../../../../components/dead-host-object.json#/properties/hsts_subdomains" | ||||
| 						}, | ||||
| 						"http2_support": { | ||||
| 							"$ref": "../../../../components/dead-host-object.json#/properties/http2_support" | ||||
| 						}, | ||||
| 						"advanced_config": { | ||||
| 							"$ref": "../../../../components/dead-host-object.json#/properties/advanced_config" | ||||
| 						}, | ||||
| 						"meta": { | ||||
| 							"$ref": "../../../../components/dead-host-object.json#/properties/meta" | ||||
| 						} | ||||
| 					} | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
| 	}, | ||||
| 	"responses": { | ||||
| 		"200": { | ||||
| 			"description": "200 response", | ||||
| 			"content": { | ||||
| 				"application/json": { | ||||
| 					"examples": { | ||||
| 						"default": { | ||||
| 							"value": { | ||||
| 								"id": 1, | ||||
| 								"created_on": "2024-10-09T01:38:52.000Z", | ||||
| 								"modified_on": "2024-10-09T01:46:06.000Z", | ||||
| 								"owner_user_id": 1, | ||||
| 								"domain_names": ["test.example.com"], | ||||
| 								"certificate_id": 0, | ||||
| 								"ssl_forced": 0, | ||||
| 								"advanced_config": "", | ||||
| 								"meta": { | ||||
| 									"nginx_online": true, | ||||
| 									"nginx_err": null | ||||
| 								}, | ||||
| 								"http2_support": 0, | ||||
| 								"enabled": 1, | ||||
| 								"hsts_enabled": 0, | ||||
| 								"hsts_subdomains": 0, | ||||
| 								"owner": { | ||||
| 									"id": 1, | ||||
| 									"created_on": "2024-10-09T00:59:56.000Z", | ||||
| 									"modified_on": "2024-10-09T00:59:56.000Z", | ||||
| 									"is_deleted": 0, | ||||
| 									"is_disabled": 0, | ||||
| 									"email": "admin@example.com", | ||||
| 									"name": "Administrator", | ||||
| 									"nickname": "Admin", | ||||
| 									"avatar": "", | ||||
| 									"roles": ["admin"] | ||||
| 								}, | ||||
| 								"certificate": null, | ||||
| 								"use_default_location": true, | ||||
| 								"ipv6": true | ||||
| 							} | ||||
| 						} | ||||
| 					}, | ||||
| 					"schema": { | ||||
| 						"$ref": "../../../../components/dead-host-object.json" | ||||
| 					} | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
		Reference in New Issue
	
	Block a user