@PostMapping(
        path = "/api/-/namespace/create",
        consumes = MediaType.APPLICATION_JSON_VALUE,
        produces = MediaType.APPLICATION_JSON_VALUE
    )
    @Operation(summary = "Create a namespace")
    @ApiResponses({
        @ApiResponse(
            responseCode = "201",
            description = "Successfully created the namespace",
            content = @Content(
                mediaType = MediaType.APPLICATION_JSON_VALUE,
                examples = @ExampleObject(value = "{ \"success\": \"Created namespace foobar\" }")
            ),
            headers = @Header(
                name = "Location",
                description = "The URL of the namespace metadata",
                schema = @Schema(type = "string")
            )
        ),
        @ApiResponse(
            responseCode = "400",
            description = "The namespace could not be created",
            content = @Content(
                mediaType = MediaType.APPLICATION_JSON_VALUE,
                examples = @ExampleObject(value = "{ \"error\": \"Invalid access token.\" }")
            )
        ),
        @ApiResponse(
            responseCode = "429",
            description = "A client has sent too many requests in a given amount of time",
            content = @Content(),
            headers = {
                @Header(
                    name = "X-Rate-Limit-Retry-After-Seconds",
                    description = "Number of seconds to wait after receiving a 429 response",
                    schema = @Schema(type = "integer", format = "int32")
                ),
                @Header(
                    name = "X-Rate-Limit-Remaining",
                    description = "Remaining number of requests left",
                    schema = @Schema(type = "integer", format = "int32")
                )
            }
        )
    })
    public ResponseEntity<ResultJson> createNamespace(
            @RequestBody @Parameter(description = "Describes the namespace to create")
            NamespaceJson namespace,
            @RequestParam @Parameter(description = "A personal access token")
            String token
    ) {
        if (namespace == null) {
            return ResponseEntity.ok(ResultJson.error("No JSON input."));
        }
        if (StringUtils.isEmpty(namespace.name)) {
            return ResponseEntity.ok(ResultJson.error("Missing required property 'name'."));
        }
        try {
            var json = local.createNamespace(namespace, token);
            var serverUrl = UrlUtil.getBaseUrl();
            var url = UrlUtil.createApiUrl(serverUrl, "api", namespace.name);
            return ResponseEntity.status(HttpStatus.CREATED)
                    .location(URI.create(url))
                    .body(json);
        } catch (ErrorResultException exc) {
            return exc.toResponseEntity();
        }
    }
@Test
    public void testCreateNamespace() throws Exception {
        mockAccessToken();
        mockMvc.perform(post("/api/-/namespace/create?token={token}", "my_token")
                .contentType(MediaType.APPLICATION_JSON)
                .content(namespaceJson(n -> { n.name = "foobar"; })))
                .andExpect(status().isCreated())
                .andExpect(redirectedUrl("http://localhost/api/foobar"))
                .andExpect(content().json(successJson("Created namespace foobar")));
    }