{"record":{"id":"23aef1a4a2058828","repo":"OpenAPITools/openapi-generator","slug":"no-openapi-specification-was-supplied","errorCode":null,"errorMessage":"No OpenAPI specification was supplied","messagePattern":"No OpenAPI specification was supplied","errorType":"http","errorClass":"ResponseStatusException","httpStatus":400,"severity":"error","filePath":"modules/openapi-generator-online/src/main/java/org/openapitools/codegen/online/service/Generator.java","lineNumber":99,"sourceCode":"        JsonNode node = opts.getSpec();\n        if (node != null && \"{}\".equals(node.toString())) {\n            LOGGER.debug(\"ignoring empty spec\");\n            node = null;\n        }\n        OpenAPI openapi;\n        ParseOptions parseOptions = new ParseOptions();\n        parseOptions.setResolve(true);\n        if (node == null) {\n            if (opts.getOpenAPIUrl() != null) {\n                if (opts.getAuthorizationValue() != null) {\n                    List<AuthorizationValue> authorizationValues = new ArrayList<>();\n                    authorizationValues.add(opts.getAuthorizationValue());\n                    openapi = new OpenAPIParser().readLocation(opts.getOpenAPIUrl(), authorizationValues, parseOptions).getOpenAPI();\n                } else {\n                    openapi = new OpenAPIParser().readLocation(opts.getOpenAPIUrl(), null, parseOptions).getOpenAPI();\n                }\n            } else {\n                throw new ResponseStatusException(HttpStatus.BAD_REQUEST, \"No OpenAPI specification was supplied\");\n            }\n        } else if (opts.getAuthorizationValue() != null) {\n            List<AuthorizationValue> authorizationValues = new ArrayList<>();\n            authorizationValues.add(opts.getAuthorizationValue());\n            openapi = new OpenAPIParser().readContents(node.toString(), authorizationValues, parseOptions).getOpenAPI();\n\n        } else {\n            openapi = new OpenAPIParser().readContents(node.toString(), null, parseOptions).getOpenAPI();\n        }\n        if (openapi == null) {\n            throw new ResponseStatusException(HttpStatus.BAD_REQUEST, \"The OpenAPI specification supplied was not valid\");\n        }\n\n\n        // do not use opts.getOptions().get(\"outputFolder\") as the input can contain ../../\n        // to access other folders in the server\n        String destPath = language + \"-\" + type.getTypeName();\n","sourceCodeStart":81,"sourceCodeEnd":117,"githubUrl":"https://github.com/OpenAPITools/openapi-generator/blob/fcec517be3cf5b7964296bcba25fbc97541484e7/modules/openapi-generator-online/src/main/java/org/openapitools/codegen/online/service/Generator.java#L81-L117","documentation":"Thrown by the generate endpoints when a GeneratorInput was supplied but contains neither a usable spec nor an openAPIUrl (Generator.java:89-100). A spec that is exactly {} is explicitly normalized to null ('ignoring empty spec', Generator.java:82-85), so it counts as absent too. The service needs exactly one source of truth — inline spec or remote URL — and refuses to generate from options alone.","triggerScenarios":"Body {\"options\":{...}} with no spec/openAPIUrl keys; body {} sent just to satisfy 285; spec sent as the literal string \"{}\" or an empty JSON object; openAPIUrl key misspelled (e.g. openApiUrl, openapiUrl) so Jackson drops it.","commonSituations":"Clients that build the request from optional config maps where both fields ended up unset; serialization bugs (wrong field name casing) silently dropping the URL; UIs with two inputs where the user filled neither.","solutions":["Include exactly one of {\"spec\": {...}} or {\"openAPIUrl\": \"https://...\"} in the request body","Check field spelling: the model expects 'spec' and 'openAPIUrl' — verify with a serialized sample request","Don't send an empty {} spec; if you have no local spec, pass the URL where it is published"],"exampleFix":"// before\nGeneratorInput in = new GeneratorInput();\nin.setOptions(Map.of(\"packageName\", \"com.acme\"));   // no spec, no url -> 400\n\n// after\nGeneratorInput in = new GeneratorInput();\nin.setOpenAPIUrl(\"https://petstore3.swagger.io/api/v3/openapi.json\");\nin.setOptions(Map.of(\"packageName\", \"com.acme\"));","handlingStrategy":"validation","validationCode":"// require exactly one spec source before sending\nboolean hasSpec = input.getSpec() != null && !\"{}\".equals(input.getSpec().toString());\nboolean hasUrl = input.getOpenAPIUrl() != null;\nif (!hasSpec && !hasUrl) throw new IllegalArgumentException(\"supply spec or openAPIUrl\");","typeGuard":"boolean hasSpecSource(GeneratorInput in) {\n    if (in == null) return false;\n    JsonNode s = in.getSpec();\n    return (s != null && !s.isNull() && !s.isEmpty()) || in.getOpenAPIUrl() != null;\n}","tryCatchPattern":null,"preventionTips":["Spell fields exactly 'spec' and 'openAPIUrl' (verify your serialized JSON)","Remember an empty {} spec is treated as absent by the server"],"tags":["http-400","openapi-spec","request-validation","openapi-generator-online"],"backgroundTag":"missing-openapi-spec","analyzedSha":"fcec517be3cf5b7964296bcba25fbc97541484e7","analyzedAt":"2026-08-22T11:13:11.613Z","schemaVersion":2},"datasetVersion":"2026-08-22T14:17:55.899Z"}