Search in sources :

Example 6 with SwaggerModelInfo

use of io.syndesis.server.connector.generator.swagger.SwaggerModelInfo in project syndesis by syndesisio.

the class SwaggerHelperTest method testThatInvalidFieldPetstoreSwaggerIsInvalid.

@Test
public void testThatInvalidFieldPetstoreSwaggerIsInvalid() throws IOException {
    final String specification = resource("/swagger/invalid/invalid-field.petstore.swagger.json");
    final SwaggerModelInfo info = SwaggerHelper.parse(specification, true);
    assertThat(info.getErrors()).hasSize(1);
    assertThat(info.getWarnings()).isEmpty();
    assertThat(info.getErrors().get(0).message()).startsWith("object instance has properties which are not allowed by the schema");
    assertThat(info.getErrors().get(0).property()).contains("/paths/~1pet/put");
    assertThat(info.getErrors().get(0).error()).contains("validation");
}
Also used : SwaggerModelInfo(io.syndesis.server.connector.generator.swagger.SwaggerModelInfo) AbstractSwaggerConnectorTest(io.syndesis.server.connector.generator.swagger.AbstractSwaggerConnectorTest) Test(org.junit.Test)

Example 7 with SwaggerModelInfo

use of io.syndesis.server.connector.generator.swagger.SwaggerModelInfo in project syndesis by syndesisio.

the class SwaggerHelperTest method testThatInvalidSchemePetstoreSwaggerIsInvalid.

@Test
public void testThatInvalidSchemePetstoreSwaggerIsInvalid() throws IOException {
    final String specification = resource("/swagger/invalid/invalid-scheme.petstore.swagger.json");
    final SwaggerModelInfo info = SwaggerHelper.parse(specification, true);
    assertThat(info.getErrors()).hasSize(1);
    assertThat(info.getWarnings()).isEmpty();
    assertThat(info.getErrors().get(0).message()).startsWith("instance value (\"httpz\") not found in enum");
    assertThat(info.getErrors().get(0).property()).contains("/schemes/0");
    assertThat(info.getErrors().get(0).error()).contains("validation");
}
Also used : SwaggerModelInfo(io.syndesis.server.connector.generator.swagger.SwaggerModelInfo) AbstractSwaggerConnectorTest(io.syndesis.server.connector.generator.swagger.AbstractSwaggerConnectorTest) Test(org.junit.Test)

Aggregations

SwaggerModelInfo (io.syndesis.server.connector.generator.swagger.SwaggerModelInfo)7 AbstractSwaggerConnectorTest (io.syndesis.server.connector.generator.swagger.AbstractSwaggerConnectorTest)5 Test (org.junit.Test)5 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)2 ProcessingException (com.github.fge.jsonschema.core.exceptions.ProcessingException)2 ProcessingMessage (com.github.fge.jsonschema.core.report.ProcessingMessage)2 ProcessingReport (com.github.fge.jsonschema.core.report.ProcessingReport)2 Violation (io.syndesis.common.model.Violation)2 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 JsonSchema (com.github.fge.jsonschema.main.JsonSchema)1 JsonSchemaFactory (com.github.fge.jsonschema.main.JsonSchemaFactory)1 HttpMethod (io.swagger.models.HttpMethod)1 ModelImpl (io.swagger.models.ModelImpl)1 Operation (io.swagger.models.Operation)1 Path (io.swagger.models.Path)1 RefModel (io.swagger.models.RefModel)1 Swagger (io.swagger.models.Swagger)1