{"record":{"id":"e871c7d04c1c4cf3","repo":"RicoSuter/NSwag","slug":"the-argument-input-was-empty","errorCode":null,"errorMessage":"The argument 'Input' was empty.","messagePattern":"The argument 'Input' was empty\\.","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/NSwag.Commands/Commands/InputOutputCommandBase.cs","lineNumber":39,"sourceCode":"        public object Input { get; set; }\n\n        [Argument(Name = \"ServiceHost\", IsRequired = false, Description = \"Overrides the service host of the web document (optional, use '.' to remove the hostname).\")]\n        public string ServiceHost { get; set; }\n\n        [Argument(Name = \"ServiceSchemes\", IsRequired = false, Description = \"Overrides the allowed schemes of the web service (optional, comma separated, 'http', 'https', 'ws', 'wss').\")]\n        public string[] ServiceSchemes { get; set; }\n\n        /// <exception cref=\"ArgumentException\">The argument 'Input' was empty.</exception>\n        protected async Task<OpenApiDocument> GetInputSwaggerDocument()\n        {\n            var document = Input as OpenApiDocument;\n            if (document == null)\n            {\n                var input = Input.ToString();\n\n                if (string.IsNullOrEmpty(input))\n                {\n                    throw new ArgumentException(\"The argument 'Input' was empty.\");\n                }\n\n                document = await ReadSwaggerDocumentAsync(input);\n            }\n\n            if (ServiceHost == \".\")\n            {\n                document.Host = string.Empty;\n                document.Schemes.Clear();\n            }\n            else\n            {\n                if (!string.IsNullOrEmpty(ServiceHost))\n                {\n                    document.Host = ServiceHost;\n                }\n\n                if (ServiceSchemes != null && ServiceSchemes.Length > 0)","sourceCodeStart":21,"sourceCodeEnd":57,"githubUrl":"https://github.com/RicoSuter/NSwag/blob/63daf8fcc3a25151b62eb4b326a1e8ea048a0d41/src/NSwag.Commands/Commands/InputOutputCommandBase.cs#L21-L57","documentation":"GetInputSwaggerDocument resolves the Swagger/OpenAPI document to process. When no document was loaded in memory, it falls back to the Input property; if that string is null or empty, it throws ArgumentException. It simply means no input document (URL, file path, or inline JSON) was supplied.","triggerScenarios":"Calling a command (e.g. openapi2csclient, webapi2openapi with /output) without setting the Input argument — e.g. `nswag openapi2csclient /output:Client.cs` with no /input, or programmatically creating a command and never assigning Input.","commonSituations":"Omitting /input on the command line; referencing a settings file that doesn't set the input variable; empty environment-variable expansion like /input:%SWAGGER_URL% resolving to nothing; calling the NSwag.Commands API in code with defaults.","solutions":["Pass an explicit input: a swagger file path, an http(s) URL, or inline JSON via the Input property (/input:...).","If input comes from a variable/config, validate it is non-empty before invoking NSwag.","Check shell quoting — an argument swallowed by quotes/whitespace can collapse to an empty value.","If the document should come from runtime generation (aspnetcore/webapi), use the matching command rather than a document-input command."],"exampleFix":"// before\nnswag openapi2csclient /output:ApiClient.cs\n\n// after\nnswag openapi2csclient /input:swagger.json /output:ApiClient.cs","handlingStrategy":"validation","validationCode":"if (string.IsNullOrWhiteSpace(input) && document == null)\n    throw new ArgumentException(\"Provide /input as a swagger file path, URL, or inline JSON before running the command.\");","typeGuard":null,"tryCatchPattern":"try { await command.GetInputSwaggerDocumentAsync(); }\ncatch (ArgumentException ex) when (ex.Message.Contains(\"argument 'Input' was empty\")) { Console.Error.WriteLine(\"Missing --input: pass a file path, URL, or inline JSON.\"); }","preventionTips":["Always include /input:... when calling document-based commands","In scripts, expand and check variables before invoking NSwag","Use quoted absolute paths to avoid shell splitting issues","Prefer .nswag config files checked into the repo so inputs are explicit"],"tags":["cli","missing-argument","input"],"backgroundTag":"empty-required-field","analyzedSha":"63daf8fcc3a25151b62eb4b326a1e8ea048a0d41","analyzedAt":"2026-09-14T11:38:15.205Z","contentChangedAt":"2026-09-14T11:38:15.205Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}