Skip to content

Commit 2b2b35e

Browse files
feat(problem+json): Add support for application/problem+json
Although rfc9457 is still in proposed status, support was already added in Java Spring environment and thus it is live in the wild. To support this while also not yet adding a huge new mechanism just warn that MUST declarations are currently not enforced by ogen. To test this sprinkle problem+json into various test files.
1 parent 8a70fb3 commit 2b2b35e

30 files changed

+1364
-15
lines changed

_testdata/examples/api.github.com.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@
166166
"200": {
167167
"description": "Response",
168168
"content": {
169-
"application/json": {
169+
"application/problem+json": {
170170
"schema": {
171171
"type": "object",
172172
"properties": {
@@ -96299,4 +96299,4 @@
9629996299
}
9630096300
}
9630196301
}
96302-
}
96302+
}

_testdata/examples/k8s.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1863,7 +1863,7 @@
18631863
],
18641864
"requestBody": {
18651865
"content": {
1866-
"application/json-patch+json": {
1866+
"application/problem+json": {
18671867
"schema": {
18681868
"$ref": "#/components/schemas/io.k8s.apimachinery.pkg.apis.meta.v1.Patch"
18691869
}

_testdata/examples/problemjson.yml

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
openapi: 3.0.1
2+
info:
3+
version: 1.0.0
4+
title: API with Problems
5+
paths:
6+
/v1/test:
7+
get:
8+
operationId: getTest
9+
responses:
10+
"200":
11+
x-summary: OK
12+
description: Process me.
13+
content:
14+
application/json:
15+
schema:
16+
type: object
17+
properties:
18+
message:
19+
type: string
20+
example: "Hello, World!"
21+
"400":
22+
x-summary: Bad Request
23+
description: |
24+
Something was wrong
25+
content:
26+
application/problem+json:
27+
schema:
28+
$ref: '#/components/schemas/ProblemJsonErrorResponse'
29+
30+
components:
31+
schemas:
32+
ProblemJsonErrorResponse:
33+
type: object
34+
description: >-
35+
An errors that occurred.
36+
required:
37+
- type
38+
- title
39+
- status
40+
properties:
41+
type:
42+
type: string
43+
description: >-
44+
Identifies the type of the problem. If the problem type has no additional semantics beyond the HTTP status code, the URI `about:blank` is used.
45+
example: "about:blank"
46+
title:
47+
type: string
48+
description: >-
49+
Roughly describes the problem. This is a static description, not a detailed one. If `type` is `about:blank`, the reason phrase of the status should be used as title.
50+
example: Not Found
51+
status:
52+
type: integer
53+
format: int32
54+
description: HTTP status code.
55+
example: 404
56+
detail:
57+
type: string
58+
description: >-
59+
Further details about the error.
60+
example: The email address could not be found.

examples/ex_github/oas_response_decoders_gen.go

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/ex_github/oas_response_encoders_gen.go

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/ex_k8s/oas_client_gen.go

+223
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/ex_k8s/oas_faker_gen.go

+22
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)