### What happened?

Consider the following custom resource:
```
apiVersion: foo.baz/v2
kind: Foo
metadata:
  name: foo
spec:
  fieldX: null
```
with the schema:
```
fieldX:
  type: string
```

This resource applies fine using `kubectl apply` or `kubectl proxy .. && curl -X POST ...`, however it fails the `TestValidateCustomResource` in `https://github.com/kubernetes/kubernetes/blob/master/staging/src/k8s.io/apiextensions-apiserver/pkg/apiserver/validation/validation_test.go`.

The following unit test passes via a call to `ValidateCustomResource()`:
```
		{
			name: "dbg",
			schema: apiextensions.JSONSchemaProps{
				Type: "object",
				Properties: map[string]apiextensions.JSONSchemaProps{
					"fieldX": {
						Type: "string",
					},
				},
			},
			failingObjects: []failingObject{
				{object: map[string]interface{}{"fieldX": nil}, expectErrs: []string{
					`fieldX: Invalid value: "null": fieldX in body must be of type string: "null"`,
				}},
			},
		},
```

Can someone explain why `kubectl apply` doesn't fail with the same error when I apply the resource? I expect to see the following error:
```
fieldX: Invalid value: "null": fieldX in body must be of type string: "null"
```

### What did you expect to happen?

Expect this to fail with `* spec.fieldX: Invalid value: "null": spec.fieldX in body must be of type string: "null"
`:
```
kubectl apply -f - <<EOF
apiVersion: foo.baz/v2
kind: Foo
metadata:
  name: foo
spec:
  fieldX: null
EOF
```

### How can we reproduce it (as minimally and precisely as possible)?

Use the examples provided.

### Anything else we need to know?

_No response_

### Kubernetes version

<details>

```console
$ kubectl version
Client Version: version.Info{Major:"1", Minor:"27", GitVersion:"v1.27.1", GitCommit:"4c9411232e10168d7b050c49a1b59f6df9d7ea4b", GitTreeState:"clean", BuildDate:"2023-04-14T13:21:19Z", GoVersion:"go1.20.3", Compiler:"gc", Platform:"linux/amd64"}
Kustomize Version: v5.0.1
Server Version: version.Info{Major:"1", Minor:"27", GitVersion:"v1.27.3", GitCommit:"25b4e43193bcda6c7328a6d147b1fb73a33f1598", GitTreeState:"clean", BuildDate:"2023-06-15T00:36:28Z", GoVersion:"go1.20.5", Compiler:"gc", Platform:"linux/amd64"}
```

</details>


### Cloud provider

Kind

### OS version

<details>

```console
# On Linux:
$ cat /etc/os-release
# paste output here
$ uname -a
# paste output here

# On Windows:
C:\> wmic os get Caption, Version, BuildNumber, OSArchitecture
# paste output here
```

</details>


### Install tools

<details>

</details>


### Container runtime (CRI) and version (if applicable)

<details>

</details>


### Related plugins (CNI, CSI, ...) and versions (if applicable)

<details>

</details>

[Question] Does the API server treat null fields in the OpenAPI schema such that it passes validation?
This is a GitHub Issue
repo:kubernetes
owner:kubernetes
Title : [Question] Does the API server treat null fields in the OpenAPI schema such that it passes validation?
Issue date:

--- start body ---
### What happened?

Consider the following custom resource:
```
apiVersion: foo.baz/v2
kind: Foo
metadata:
  name: foo
spec:
  fieldX: null
```
with the schema:
```
fieldX:
  type: string
```

This resource applies fine using `kubectl apply` or `kubectl proxy .. && curl -X POST ...`, however it fails the `TestValidateCustomResource` in `https://github.com/kubernetes/kubernetes/blob/master/staging/src/k8s.io/apiextensions-apiserver/pkg/apiserver/validation/validation_test.go`.

The following unit test passes via a call to `ValidateCustomResource()`:
```
		{
			name: "dbg",
			schema: apiextensions.JSONSchemaProps{
				Type: "object",
				Properties: map[string]apiextensions.JSONSchemaProps{
					"fieldX": {
						Type: "string",
					},
				},
			},
			failingObjects: []failingObject{
				{object: map[string]interface{}{"fieldX": nil}, expectErrs: []string{
					`fieldX: Invalid value: "null": fieldX in body must be of type string: "null"`,
				}},
			},
		},
```

Can someone explain why `kubectl apply` doesn't fail with the same error when I apply the resource? I expect to see the following error:
```
fieldX: Invalid value: "null": fieldX in body must be of type string: "null"
```

### What did you expect to happen?

Expect this to fail with `* spec.fieldX: Invalid value: "null": spec.fieldX in body must be of type string: "null"
`:
```
kubectl apply -f - <<EOF
apiVersion: foo.baz/v2
kind: Foo
metadata:
  name: foo
spec:
  fieldX: null
EOF
```

### How can we reproduce it (as minimally and precisely as possible)?

Use the examples provided.

### Anything else we need to know?

_No response_

### Kubernetes version

<details>

```console
$ kubectl version
Client Version: version.Info{Major:"1", Minor:"27", GitVersion:"v1.27.1", GitCommit:"4c9411232e10168d7b050c49a1b59f6df9d7ea4b", GitTreeState:"clean", BuildDate:"2023-04-14T13:21:19Z", GoVersion:"go1.20.3", Compiler:"gc", Platform:"linux/amd64"}
Kustomize Version: v5.0.1
Server Version: version.Info{Major:"1", Minor:"27", GitVersion:"v1.27.3", GitCommit:"25b4e43193bcda6c7328a6d147b1fb73a33f1598", GitTreeState:"clean", BuildDate:"2023-06-15T00:36:28Z", GoVersion:"go1.20.5", Compiler:"gc", Platform:"linux/amd64"}
```

</details>


### Cloud provider

Kind

### OS version

<details>

```console
# On Linux:
$ cat /etc/os-release
# paste output here
$ uname -a
# paste output here

# On Windows:
C:\> wmic os get Caption, Version, BuildNumber, OSArchitecture
# paste output here
```

</details>


### Install tools

<details>

</details>


### Container runtime (CRI) and version (if applicable)

<details>

</details>


### Related plugins (CNI, CSI, ...) and versions (if applicable)

<details>

</details>

--- end body ---

None