🇺🇸 English | 🇷🇺 Русский | 🇨🇳 中文
Removes a parameter from an endpoint in the OpenAPI specification
| Parameter | Description | Example | Typing | Default |
|---|---|---|---|---|
endpointDescriptor |
[required] Description of the endpoint from which to remove the parameter | "GET /pets" |
string \ { path: string; method: string } |
- |
parameterDescriptor |
[required] Description of the parameter to remove. In the in parameter, you can specify: "query", "path", "header", "cookie". |
{"name": "petId", "in": "path"} |
{ name: string; in: "query" \ "path" \ "header" \ "cookie" } |
- |
Configuration example:
module.exports = {
pipeline: [
// ... other rules
{
rule: "remove-parameter",
config: {
endpointDescriptor: "GET /pets/{petId}", // specify the endpoint from which to remove the parameter
parameterDescriptor: {
name: "version", // specify the name of the parameter to be deleted
in: "query" // specify the parameter location (query parameter)
}
},
}
// ... other rules
]
}If you need to modify multiple specifications, you can use this rule multiple times in the overall configuration pipeline.
Practical example:
In the openapi.yaml file, the endpoint documentation looks like this:
paths:
/pets/{petId}:
get:
summary: Get pet by ID
parameters:
- name: petId
in: path
required: true
schema:
type: string
- name: version
in: query
required: false
schema:
type: stringNeed to remove the unused parameter version.
In the configuration file openapi-modifier-config.js, add the remove-parameter rule:
module.exports = {
pipeline: [
{
rule: "remove-parameter",
config: {
endpointDescriptor: "GET /pets/{petId}",
parameterDescriptor: {
name: "version",
in: "query"
}
},
}
]
}After applying the rule, the openapi.yaml file looks like this:
paths:
/pets/{petId}:
get:
summary: Get pet by ID
parameters:
- name: petId
in: path
required: true
schema:
type: stringPractical example:
In the openapi.yaml file, there is a component with a parameter:
components:
parameters:
ApiKeyHeader:
name: X-API-Key
in: header
required: true
schema:
type: stringNeed to remove the ApiKeyHeader parameter component.
In the configuration file openapi-modifier-config.js, add the remove-parameter rule:
module.exports = {
pipeline: [
{
rule: "remove-parameter",
config: {
parameterDescriptor: {
name: "X-API-Key",
in: "header"
}
},
}
]
}After applying the rule, the openapi.yaml file looks like this:
components:
parameters: {}- If the endpoint or parameter is not found, the rule outputs a warning and leaves the specification unchanged, for timely updating of the openapi-modifier configuration
- The rule can be applied to parameters of any type (query, path, header, cookie)