diff --git a/microprofile-openapi/README-source.adoc b/microprofile-openapi/README-source.adoc index 4a83ca7622..0be9c81a93 100644 --- a/microprofile-openapi/README-source.adoc +++ b/microprofile-openapi/README-source.adoc @@ -42,77 +42,84 @@ Run following command in your terminal: $ curl http://localhost:8080/openapi ---- -It should return a YAML document conforming to the http://spec.openapis.org/oas/v3.0.3[OpenAPI specification]: +It should return a YAML document conforming to the https://spec.openapis.org/oas/v3.1.0[OpenAPI specification]: [source, yaml] ---- -openapi: 3.0.1 +components: + schemas: + Fruit: + type: object + properties: + name: + type: string + description: + type: string +externalDocs: {} info: - title: Store inventory + contact: {} description: Application for tracking store inventory + license: {} + title: Store inventory version: "1.0" -servers: -- url: /microprofile-openapi +openapi: 3.1.0 paths: - /: + /microprofile-openapi/: get: responses: "200": - description: OK content: text/plain: schema: type: string - /fruit: - get: - responses: - "200": description: OK - content: - application/json: - schema: - type: array - items: - $ref: '#/components/schemas/Fruit' - post: + /microprofile-openapi/fruit: + delete: requestBody: content: application/json: schema: - $ref: '#/components/schemas/Fruit' + $ref: "#/components/schemas/Fruit" + required: true responses: "200": - description: OK content: application/json: schema: + items: + $ref: "#/components/schemas/Fruit" type: array + uniqueItems: true + description: OK + get: + responses: + "200": + content: + application/json: + schema: items: - $ref: '#/components/schemas/Fruit' - delete: + $ref: "#/components/schemas/Fruit" + type: array + uniqueItems: true + description: OK + post: requestBody: content: application/json: schema: - $ref: '#/components/schemas/Fruit' + $ref: "#/components/schemas/Fruit" + required: true responses: "200": - description: OK content: application/json: schema: - type: array items: - $ref: '#/components/schemas/Fruit' -components: - schemas: - Fruit: - type: object - properties: - description: - type: string - name: - type: string + $ref: "#/components/schemas/Fruit" + type: array + uniqueItems: true + description: OK +servers: [] ---- === Enhance OpenAPI documentation with annotations diff --git a/microprofile-openapi/src/test/java/org/wildfly/quickstart/microprofile/openapi/OpenAPIContextIT.java b/microprofile-openapi/src/test/java/org/wildfly/quickstart/microprofile/openapi/OpenAPIContextIT.java index 4bbe416cd5..3f30516417 100644 --- a/microprofile-openapi/src/test/java/org/wildfly/quickstart/microprofile/openapi/OpenAPIContextIT.java +++ b/microprofile-openapi/src/test/java/org/wildfly/quickstart/microprofile/openapi/OpenAPIContextIT.java @@ -14,6 +14,7 @@ import java.net.http.HttpRequest; import java.net.http.HttpResponse; import java.time.Duration; +import java.util.Arrays; import org.junit.Test; @@ -47,9 +48,8 @@ public void testOpenAPIContextIsAvailable() throws IOException, InterruptedExcep final HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString()); assertEquals("/openapi context is not available", 200, response.statusCode()); - // First line are just dashes, so lets check the second line with OpenAPI version key for the prefix String[] bodyLines = response.body().split("\n"); - assertTrue(bodyLines[1].startsWith("openapi:")); + assertTrue("Document does not contain \"openapi:\" field", Arrays.stream(bodyLines).anyMatch(line -> line.startsWith("openapi:"))); } }