Skip to content
2 changes: 1 addition & 1 deletion api-design/http-methods.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ description: "Design intuitive, validated request bodies that make your API easy
We learned about URLs in _[What is a URL?](/api-design/urls)_ which is how an
API defines its "resources". If an API request were a sentence, the URL would be the noun. In this section, we'll cover the verbs of API requests: HTTP methods.

```curl focus:1[1:3]
```curl
GET /places?lat=40.759211&lon=-73.984638 HTTP/1.1
Host: api.example.org
```
Expand Down
2 changes: 1 addition & 1 deletion openapi/schemas/composition.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ This can be done for a single value:

```yaml
properties:
created_at:
created_at:
oneOf:
- type: string
format: date-time
Expand Down
22 changes: 11 additions & 11 deletions openapi/schemas/enums.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ paths:

If you use `default`, remember to omit `required: true` from the field.

## Enums With Names and Values
## Enums with names and values

A common requirement using enums is to specify a human-readable name for the enum label and an integer for the enum value. For example, in C#:

Expand Down Expand Up @@ -196,9 +196,9 @@ components:
description: Small Medium Large
```

## Constants for Single Value Enums
## Constants for single value enums

Before JSON Schema 2019 was included in OpenAPI 3.1, using an enum with a single value was the only way to specify a constant. If you are still using OpenAPI 3.0, the example below shows how to specify that a constant string is returned in a response:
Before JSON Schema 2019 was included in OpenAPI v3.1, using an enum with a single value was the only way to specify a constant. If you are still using OpenAPI v3.0, the example below shows how to specify that a constant string is returned in a response:

```yaml
openapi: 3.0.0
Expand All @@ -219,7 +219,7 @@ paths:
- Here is your beverage
```

When using OpenAPI 3.1, you can use the `const` keyword whose name more clearly matches its intention than `enum` does:
When using OpenAPI v3.1, you can use the `const` keyword whose name more clearly matches its intention than `enum` does:

```yaml
openapi: 3.1.0
Expand All @@ -239,11 +239,11 @@ paths:
const: Here is your beverage
```

## Nullable Enums
## Nullable enums

### OpenAPI 3.0
### OpenAPI v3.0

In OpenAPI 3.0 you can use the `nullable` keyword to specify `null` as an accepted value in an enum. In the example below, a client can order a drink with one of three cup sizes or no cup size specified at all:
In OpenAPI v3.0 you can use the `nullable` keyword to specify `null` as an accepted value in an enum. In the example below, a client can order a drink with one of three cup sizes or no cup size specified at all:

```yaml
# !focus(6)
Expand All @@ -259,9 +259,9 @@ components:
- LARGE
```

### OpenAPI 3.1
### OpenAPI v3.1

OpenAPI 3.1 more closely aligns with the JSON Schema standard. As a result, the way to specify nullable types differs from OpenAPI 3.0. Instead of using the `nullable` attribute, OpenAPI 3.1 uses the JSON Schema approach with an array of types - including the `null` type. Here's the same example adapted for OpenAPI 3.1:
OpenAPI v3.1 more closely aligns with the JSON Schema standard. As a result, the way to specify nullable types differs from OpenAPI 3.0. Instead of using the `nullable` attribute, OpenAPI v3.1 uses the JSON Schema approach with an array of types - including the `null` type. Here's the same example adapted for OpenAPI v3.1:

```yaml
# !focus(5,10)
Expand All @@ -277,7 +277,7 @@ components:
- null
```

## Open Enums
## Open enums

Traditionally enums are closed, meaning that only the values listed in the enum are allowed. In contrast, open enums allow additional values beyond those explicitly defined in the spec. Open Enums are useful when your API is evolving to support new use cases. In that scenario, you can let clients send values that aren't defined yet because their usage is on the edge of your API's capabilities.

Expand Down Expand Up @@ -349,7 +349,7 @@ components:

Date objects are not directly supported. Export your dates to ISO strings before using them in an API.

## Best Practices
## Best practices

Enums are simple, so there are only a few things to consider when using them in your schema:

Expand Down
4 changes: 2 additions & 2 deletions openapi/schemas/null.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ schema:
nullable: true
```

## OpenAPI 3.1.X
## OpenAPI v3.1

OpenAPI 3.1 aligned describing `null` with JSON Schema. This allows for more precise API definitions, especially for APIs that need to explicitly support null values as valid inputs or outputs.
OpenAPI v3.1 aligned describing `null` with JSON Schema. This allows for more precise API definitions, especially for APIs that need to explicitly support null values as valid inputs or outputs.

To specify that a property, item, or response can be `null`, you can use the `type` keyword with a value of `null` or combine null with other types using the `oneOf` or type array syntax. This flexibility makes it easier to accurately model your data.

Expand Down
Loading
Loading