Search in sources :

Example 1 with BinarySchema

use of io.swagger.v3.oas.models.media.BinarySchema in project swagger-core by swagger-api.

the class ByteConverterTest method testReadOnlyByteArray.

@Test
public void testReadOnlyByteArray() {
    Schema model = new Schema().addProperties("byteArray", new ArraySchema().items(new BinarySchema()).readOnly(true));
    assertEquals(Json.pretty(model), "{" + NEWLINE + "  \"properties\" : {" + NEWLINE + "    \"byteArray\" : {" + NEWLINE + "      \"type\" : \"array\"," + NEWLINE + "      \"readOnly\" : true," + NEWLINE + "      \"items\" : {" + NEWLINE + "        \"type\" : \"string\"," + NEWLINE + "        \"format\" : \"binary\"" + NEWLINE + "      }" + NEWLINE + "    }" + NEWLINE + "  }" + NEWLINE + "}");
}
Also used : ByteArraySchema(io.swagger.v3.oas.models.media.ByteArraySchema) ArraySchema(io.swagger.v3.oas.models.media.ArraySchema) BinarySchema(io.swagger.v3.oas.models.media.BinarySchema) BinarySchema(io.swagger.v3.oas.models.media.BinarySchema) Schema(io.swagger.v3.oas.models.media.Schema) ByteArraySchema(io.swagger.v3.oas.models.media.ByteArraySchema) ArraySchema(io.swagger.v3.oas.models.media.ArraySchema) Test(org.testng.annotations.Test)

Example 2 with BinarySchema

use of io.swagger.v3.oas.models.media.BinarySchema in project swagger-core by swagger-api.

the class ByteConverterTest method testByteArray.

@Test
public void testByteArray() {
    Schema model = new Schema().addProperties("byteArray", new ArraySchema().items(new BinarySchema()));
    assertEquals(Json.pretty(model), "{" + NEWLINE + "  \"properties\" : {" + NEWLINE + "    \"byteArray\" : {" + NEWLINE + "      \"type\" : \"array\"," + NEWLINE + "      \"items\" : {" + NEWLINE + "        \"type\" : \"string\"," + NEWLINE + "        \"format\" : \"binary\"" + NEWLINE + "      }" + NEWLINE + "    }" + NEWLINE + "  }" + NEWLINE + "}");
}
Also used : ByteArraySchema(io.swagger.v3.oas.models.media.ByteArraySchema) ArraySchema(io.swagger.v3.oas.models.media.ArraySchema) BinarySchema(io.swagger.v3.oas.models.media.BinarySchema) BinarySchema(io.swagger.v3.oas.models.media.BinarySchema) Schema(io.swagger.v3.oas.models.media.Schema) ByteArraySchema(io.swagger.v3.oas.models.media.ByteArraySchema) ArraySchema(io.swagger.v3.oas.models.media.ArraySchema) Test(org.testng.annotations.Test)

Example 3 with BinarySchema

use of io.swagger.v3.oas.models.media.BinarySchema in project swagger-parser by swagger-api.

the class OpenAPIDeserializerTest method testDeserializeBinaryString.

@Test
public void testDeserializeBinaryString() {
    String yaml = "openapi: 3.0.0\n" + "servers: []\n" + "info:\n" + "  title: foo\n" + "  version: ''\n" + "paths:\n" + "  /test:\n" + "    post:\n" + "      responses:\n" + "        '200':\n" + "          description: ok\n" + "      requestBody:\n" + "        content:\n" + "          application/json:\n" + "            schema:\n" + "              type: string\n" + "              format: binary";
    OpenAPIV3Parser parser = new OpenAPIV3Parser();
    SwaggerParseResult result = parser.readContents(yaml, null, null);
    final OpenAPI resolved = new OpenAPIResolver(result.getOpenAPI(), null).resolve();
    assertTrue(resolved.getPaths().get("/test").getPost().getRequestBody().getContent().get("application/json").getSchema() instanceof BinarySchema);
}
Also used : BinarySchema(io.swagger.v3.oas.models.media.BinarySchema) OpenAPIResolver(io.swagger.v3.parser.OpenAPIResolver) SwaggerParseResult(io.swagger.v3.parser.core.models.SwaggerParseResult) OpenAPIV3Parser(io.swagger.v3.parser.OpenAPIV3Parser) OpenAPI(io.swagger.v3.oas.models.OpenAPI) Test(org.testng.annotations.Test)

Aggregations

BinarySchema (io.swagger.v3.oas.models.media.BinarySchema)3 Test (org.testng.annotations.Test)3 ArraySchema (io.swagger.v3.oas.models.media.ArraySchema)2 ByteArraySchema (io.swagger.v3.oas.models.media.ByteArraySchema)2 Schema (io.swagger.v3.oas.models.media.Schema)2 OpenAPI (io.swagger.v3.oas.models.OpenAPI)1 OpenAPIResolver (io.swagger.v3.parser.OpenAPIResolver)1 OpenAPIV3Parser (io.swagger.v3.parser.OpenAPIV3Parser)1 SwaggerParseResult (io.swagger.v3.parser.core.models.SwaggerParseResult)1