Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 42 additions & 35 deletions microprofile-openapi/README-source.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -47,9 +48,8 @@ public void testOpenAPIContextIsAvailable() throws IOException, InterruptedExcep
final HttpResponse<String> 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:")));
}

}
Loading