> For the complete documentation index, see [llms.txt](https://cortex-docs.paloaltonetworks.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://cortex-docs.paloaltonetworks.com/appsec-rules/iac-security/public-exposure/appsec-openapi-1.md).

# OpenAPI Security Definitions Object should be set and not empty misconfiguration detected in code

## Rule Details

|                        |                        |
| ---------------------- | ---------------------- |
| Cortex AppSec Rule ID  | APPSEC\_OPENAPI\_1     |
| Category - Subcategory | Public Exposure - APIs |
| Provider               | OTHER                  |
| Severity               | HIGH                   |
| Framework              | OpenAPI                |

## Impact

Define the authentication types that your API supports for OpenAPI/Swagger 2.0 in securityDefinitions. HNot defining authentication types exposes your APIs to attacks, while not documenting the authentication type makes it more difficult to understand how to access your API.

## How to Fix

To fix this issue, you need to ensure that every operation object for PUT, POST and PATCH in your OpenAPI description (version 2.0 files) has the 'consumes' field defined. The 'consumes' field indicates what MIME types the operation can consume.

## In the fixed code, the 'consumes' field is clearly defined under the POST operation. This is important as it informs clients what type of content the operation can consume, further avoiding any client sending the wrong content type to the server. This also ensures that the API is secure as it only accepts the defined format. \[source,go]

## paths: /users: post: summary: Creates a new user. consumes: # Add this field - application/json parameters: - in: body name: user description: The user to create. schema: $ref: '#/definitions/User'


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://cortex-docs.paloaltonetworks.com/appsec-rules/iac-security/public-exposure/appsec-openapi-1.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
