Skip to content

Commit

Permalink
Implemented DeleteAllResponsesCommand.
Browse files Browse the repository at this point in the history
  • Loading branch information
EricWittmann committed Jan 6, 2025
1 parent d37bb69 commit 1ea6fc8
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 33 deletions.
5 changes: 5 additions & 0 deletions src/main/java/io/apicurio/datamodels/cmd/CommandFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import io.apicurio.datamodels.cmd.commands.DeleteAllOperationsCommand;
import io.apicurio.datamodels.cmd.commands.DeleteAllParametersCommand;
import io.apicurio.datamodels.cmd.commands.DeleteAllPropertiesCommand;
import io.apicurio.datamodels.cmd.commands.DeleteAllResponsesCommand;
import io.apicurio.datamodels.cmd.commands.DeleteContactCommand;
import io.apicurio.datamodels.cmd.commands.DeleteExtensionCommand;
import io.apicurio.datamodels.cmd.commands.DeleteLicenseCommand;
Expand Down Expand Up @@ -120,4 +121,8 @@ public static final ICommand createDeleteAllPropertiesCommand(Schema schema) {
return new DeleteAllPropertiesCommand(schema);
}

public static final ICommand createDeleteAllResponsesCommand(OpenApiOperation operation) {
return new DeleteAllResponsesCommand(operation);
}

}
Original file line number Diff line number Diff line change
@@ -1,19 +1,3 @@
/*
* Copyright 2019 Red Hat
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package io.apicurio.datamodels.cmd.commands;

import com.fasterxml.jackson.databind.node.ObjectNode;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,3 @@
/*
* Copyright 2019 Red Hat
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package io.apicurio.datamodels.cmd.commands;

import com.fasterxml.jackson.databind.node.ObjectNode;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package io.apicurio.datamodels.cmd.commands;

import com.fasterxml.jackson.databind.node.ObjectNode;
import io.apicurio.datamodels.Library;
import io.apicurio.datamodels.models.Document;
import io.apicurio.datamodels.models.openapi.OpenApiOperation;
import io.apicurio.datamodels.models.openapi.OpenApiResponses;
import io.apicurio.datamodels.paths.NodePathUtil;

/**
* @author [email protected]
*/
public class DeleteAllResponsesCommand extends DeleteNodeCommand<OpenApiResponses> {

public DeleteAllResponsesCommand() {
}

public DeleteAllResponsesCommand(OpenApiOperation operation) {
super("responses", operation);
}

@Override
protected OpenApiResponses readNode(Document doc, ObjectNode node) {
OpenApiOperation operation = (OpenApiOperation) NodePathUtil.resolveNodePath(this._parentPath, doc);
OpenApiResponses responses = operation.createResponses();
Library.readNode(node, responses);
return responses;
}

}
2 changes: 2 additions & 0 deletions src/main/ts/src/io/apicurio/datamodels/util/CommandUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {DeleteAllHeadersCommand} from "../cmd/commands/DeleteAllHeadersCommand";
import {DeleteAllOperationsCommand} from "../cmd/commands/DeleteAllOperationsCommand";
import {DeleteAllParametersCommand} from "../cmd/commands/DeleteAllParametersCommand";
import {DeleteAllPropertiesCommand} from "../cmd/commands/DeleteAllPropertiesCommand";
import {DeleteAllResponsesCommand} from "../cmd/commands/DeleteAllResponsesCommand";
import {DeleteContactCommand} from "../cmd/commands/DeleteContactCommand";
import {DeleteExtensionCommand} from "../cmd/commands/DeleteExtensionCommand";
import {DeleteLicenseCommand} from "../cmd/commands/DeleteLicenseCommand";
Expand Down Expand Up @@ -52,6 +53,7 @@ const commandSuppliers: { [key: string]: Supplier } = {
"DeleteAllOperationsCommand": () => { return new DeleteAllOperationsCommand(); },
"DeleteAllParametersCommand": () => { return new DeleteAllParametersCommand(); },
"DeleteAllPropertiesCommand": () => { return new DeleteAllPropertiesCommand(); },
"DeleteAllResponsesCommand": () => { return new DeleteAllResponsesCommand(); },
"DeleteContactCommand": () => { return new DeleteContactCommand(); },
"DeleteExtensionCommand": () => { return new DeleteExtensionCommand(); },
"DeleteLicenseCommand": () => { return new DeleteLicenseCommand(); },
Expand Down
4 changes: 3 additions & 1 deletion src/test/resources/fixtures/cmd/tests.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,7 @@
{ "name": "[OpenAPI 3] {Delete All Params} - Delete All Params", "test" : "commands/delete-all-parameters/openapi-3/delete-all-parameters" },
{ "name": "[OpenAPI 2] {Delete All Properties} - Delete All Properties", "test": "commands/delete-all-properties/openapi-2/delete-all-properties" },
{ "name": "[OpenAPI 3] {Delete All Properties} - Delete All Properties", "test": "commands/delete-all-properties/openapi-3/delete-all-properties" },
{ "name": "[AsyncAPI 2] {Delete All Properties} - Delete All Properties", "test": "commands/delete-all-properties/asyncapi-2/delete-all-properties" }
{ "name": "[AsyncAPI 2] {Delete All Properties} - Delete All Properties", "test": "commands/delete-all-properties/asyncapi-2/delete-all-properties" },
{ "name": "[OpenAPI 2] {Delete All Responses} - Delete All Responses", "test": "commands/delete-all-responses/openapi-2/delete-all-responses" },
{ "name": "[OpenAPI 3] {Delete All Responses} - Delete All Responses", "test": "commands/delete-all-responses/openapi-3/delete-all-responses" }
]

0 comments on commit 1ea6fc8

Please sign in to comment.