Skip to content

Commit

Permalink
Rename getDbSchema
Browse files Browse the repository at this point in the history
  • Loading branch information
javiertuya committed Jun 22, 2024
1 parent cd3e227 commit 7c0dc30
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public OaSchemaApi setFilter(OaSchemaFilter filter) {
* (note: fails if location is invalid or contains an invalid specification)
*/
@SuppressWarnings("rawtypes")
public TdSchema getDbSchema() {
public TdSchema getSchema() {
OpenAPI openApi = parseOpenApi();

Map<String, Schema> oaSchemas = getOaSchemas(openApi);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public void testSchemaBasicTypesAndConstraints() throws IOException {
String fileName = "issue-gitlab-rp-12-marketArrays";
OaSchemaApi oas1 = new OaSchemaApi(FileUtil.getPath(TEST_PATH_INPUT, "issue-gitlab-rp-12-marketArrays" +".json"))
.setIdResolver(new OaSchemaIdResolver().setIdName("id").setIdName("productId"));
TdSchema schema1 = oas1.getDbSchema();
TdSchema schema1 = oas1.getSchema();
String schema1Xml =new TdSchemaXmlSerializer().serialize(schema1);
fileWrite(TEST_PATH_OUTPUT, "issue-gitlab-rp-12-marketArrays" + ".xml", schema1Xml);
assertModelXml(fileName, schema1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,97 +19,97 @@ public class TestSchemaConvert extends Base {

@Test
public void testSchemaBasicTypesAndNulEnum() throws IOException {
TdSchema schema = getDbApi("oa-basic.yml").getDbSchema();
TdSchema schema = getDbApi("oa-basic.yml").getSchema();
assertModel("schema-basic.txt", schema);
}

@Test
public void testSchemaBasicTypesWithConstraints() throws IOException {
TdSchema schema = getDbApi("oa-constraints.yml").getDbSchema();
TdSchema schema = getDbApi("oa-constraints.yml").getSchema();
assertModel("schema-constraints.txt", schema);
}

@Test
public void testSchemaObjectTypes() throws IOException {
TdSchema schema = getDbApi("oa-object.yml").getDbSchema();
TdSchema schema = getDbApi("oa-object.yml").getSchema();
assertModel("schema-object.txt", schema);
}

@Test
public void testSchemaObjectTypesMermaid() throws IOException {
OaSchemaApi api = getDbApi("oa-object.yml");
String mermaid = new MermaidWriter(api.getDbSchema()).getMermaid();
String mermaid = new MermaidWriter(api.getSchema()).getMermaid();
assertModelMermaid("schema-object.md", mermaid);
}

@Test
public void testSchemaObjectNullableTypes() throws IOException {
TdSchema schema = getDbApi("oa-object-nullable.yml").getDbSchema();
TdSchema schema = getDbApi("oa-object-nullable.yml").getSchema();
assertModel("schema-object-nullable.txt", schema);
}

@Test
public void testSchemaArrayTypes() throws IOException {
TdSchema schema = getDbApi("oa-array.yml").getDbSchema();
TdSchema schema = getDbApi("oa-array.yml").getSchema();
assertModel("schema-array.txt", schema);
}

@Test
public void testSchemaArrayTypesMermaid() throws IOException {
OaSchemaApi api = getDbApi("oa-array.yml");
String mermaid = new MermaidWriter(api.getDbSchema()).getMermaid();
String mermaid = new MermaidWriter(api.getSchema()).getMermaid();
assertModelMermaid("schema-array.md", mermaid);
}

@Test
public void testSchemaArrayWithFks() throws IOException {
TdSchema schema = getDbApi("oa-array-with-fk.yml").getDbSchema();
TdSchema schema = getDbApi("oa-array-with-fk.yml").getSchema();
assertModel("schema-array-with-fk.txt", schema);
}

@Test
public void testSchemaArrayWithFksMermaid() throws IOException {
OaSchemaApi api = getDbApi("oa-array-with-fk.yml");
String mermaid = new MermaidWriter(api.getDbSchema()).getMermaid();
String mermaid = new MermaidWriter(api.getSchema()).getMermaid();
assertModelMermaid("schema-array-with-fk.md", mermaid);
}

@Test
public void testSchemaNestedCompositeObject() throws IOException {
TdSchema schema = getDbApi("oa-nested-obj.yml").getDbSchema();
TdSchema schema = getDbApi("oa-nested-obj.yml").getSchema();
assertModel("schema-nested-obj.txt", schema);
}

@Test
public void testSchemaNestedCompositeObjectMermaid() throws IOException {
OaSchemaApi api = getDbApi("oa-nested-obj.yml");
String mermaid = new MermaidWriter(api.getDbSchema()).getMermaid();
String mermaid = new MermaidWriter(api.getSchema()).getMermaid();
assertModelMermaid("schema-nested-obj.md", mermaid);
}

@Test
public void testSchemaNestedCompositeArray() throws IOException {
TdSchema schema = getDbApi("oa-nested-arr.yml").getDbSchema();
TdSchema schema = getDbApi("oa-nested-arr.yml").getSchema();
assertModel("schema-nested-arr.txt", schema);
}

@Test
public void testSchemaNestedCompositeArrayMermaid() throws IOException {
OaSchemaApi api = getDbApi("oa-nested-arr.yml");
String mermaid = new MermaidWriter(api.getDbSchema()).getMermaid();
String mermaid = new MermaidWriter(api.getSchema()).getMermaid();
assertModelMermaid("schema-nested-arr.md", mermaid);
}

// Special chars must pass without changes to the model, except references between entities
@Test
public void testSchemaUnreservedChars() throws IOException {
TdSchema schema = getDbApi("oa-chars.yml").getDbSchema();
TdSchema schema = getDbApi("oa-chars.yml").getSchema();
assertModel("schema-chars.txt", schema);
}

@Test
public void testSchemaUnreservedCharsXml() throws IOException {
TdSchema schema = getDbApi("oa-chars.yml").getDbSchema();
TdSchema schema = getDbApi("oa-chars.yml").getSchema();
assertModelXml("schema-chars", schema);
}

Expand All @@ -118,15 +118,15 @@ public void testSchemaUnreservedCharsXml() throws IOException {
@Test
public void testSchemaIdResolver() throws IOException {
OaSchemaApi api = getDbApi("oa-ids.yml").setIdResolver(new OaSchemaIdResolver().setIdName("uid"));
TdSchema schema = api.getDbSchema();
TdSchema schema = api.getSchema();
assertModel("schema-ids.txt", schema);
}

@Test
public void testSchemaIdResolverWithExclusions() throws IOException {
OaSchemaApi api = getDbApi("oa-ids-exclusions.yml")
.setIdResolver(new OaSchemaIdResolver().setIdName("uid").excludeEntity("With"));
TdSchema schema = api.getDbSchema();
TdSchema schema = api.getSchema();
assertModel("schema-ids-exclusions.txt", schema);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class TestSchemaFilter extends Base {
*/
@Test
public void testSchemaFilterBaseline() throws IOException {
TdSchema schema = getDbApi("oa-filter.yml").getDbSchema();
TdSchema schema = getDbApi("oa-filter.yml").getSchema();
assertModel("schema-filter-baseline.txt", schema);
}

Expand All @@ -32,7 +32,7 @@ public void testSchemaFilterBaseline() throws IOException {
public void testSchemaFilterEntityAndAttribute() throws IOException {

OaSchemaFilter filter = new OaSchemaFilter().add("nokey*", "*").add("*", "string*");
TdSchema schema = getDbApi("oa-filter.yml").setFilter(filter).getDbSchema();
TdSchema schema = getDbApi("oa-filter.yml").setFilter(filter).getSchema();
assertModel("schema-filter-entity-attribute.txt", schema);
}

Expand All @@ -42,7 +42,7 @@ public void testSchemaFilterEntityAndAttribute() throws IOException {
@Test
public void testSchemaFilterComposites() throws IOException {
OaSchemaFilter filter = new OaSchemaFilter().add("empty*", "*").add("*", "arr*").add("*", "obj*");
TdSchema schema = getDbApi("oa-filter.yml").setFilter(filter).getDbSchema();
TdSchema schema = getDbApi("oa-filter.yml").setFilter(filter).getSchema();
assertModel("schema-filter-composites.txt", schema);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class TestValidationPublicSchemas extends Base {
@Test
public void testPetstoreOriginal() throws IOException {
OaSchemaApi api = getDbApi("public-swagger-petstore-v3-1.0.17.yaml");
TdSchema schema = api.getDbSchema();
TdSchema schema = api.getSchema();
assertModel("public-swagger-petstore-v3-1.0.17.txt", schema);
assertEquals("WARN Can't get the rid for array Customer_address_xa because it has not any upstream with uid\n"
+ "WARN Can't get the rid for array Pet_photoUrls_xa because it has not any upstream with uid\n"
Expand All @@ -36,7 +36,7 @@ public void testPetstoreOriginal() throws IOException {
public void testPetstoreOriginalIdsByConvention() throws IOException {
OaSchemaApi api = getDbApi("public-swagger-petstore-v3-1.0.17.yaml")
.setIdResolver(new OaSchemaIdResolver().setIdName("id").excludeEntity("Tag"));
TdSchema schema = api.getDbSchema();
TdSchema schema = api.getSchema();
assertModel("public-swagger-petstore-v3-1.0.17-with-ids-by-convention.txt", schema);
assertEquals("", api.getOaLogs());
}
Expand All @@ -45,15 +45,15 @@ public void testPetstoreOriginalIdsByConvention() throws IOException {
@Test
public void testPetstoreWithIds() throws IOException {
OaSchemaApi api = getDbApi("public-swagger-petstore-v3-1.0.17-with-ids.yaml");
TdSchema schema = api.getDbSchema();
TdSchema schema = api.getSchema();
assertModel("public-swagger-petstore-v3-1.0.17-with-ids.txt", schema);
assertEquals("", api.getOaLogs());
}

@Test
public void testPetstoreWithIdsMermaid() throws IOException {
OaSchemaApi api = getDbApi("public-swagger-petstore-v3-1.0.17-with-ids.yaml");
String mermaid = new MermaidWriter(api.getDbSchema()).getMermaid();
String mermaid = new MermaidWriter(api.getSchema()).getMermaid();
assertModelMermaid("public-swagger-petstore-v3-1.0.17-with-ids.md", mermaid);
}

Expand All @@ -63,7 +63,7 @@ public void testPetstoreWithIdsMermaid() throws IOException {
public void testGestaoHospital() throws IOException {
OaSchemaApi api = getDbApi("public-GestaoHospital-original-20290410.json")
.setIdResolver(new OaSchemaIdResolver().setIdName("id"));
TdSchema schema = api.getDbSchema();
TdSchema schema = api.getSchema();
assertModel("public-GestaoHospital-original-20290410.txt", schema);
assertEquals("WARN Can't get the rid for array GeoJsonPoint_coordinates_xa because it has not any upstream with uid",
api.getOaLogs());
Expand All @@ -73,7 +73,7 @@ public void testGestaoHospital() throws IOException {
public void testGestaoHospitalMermaid() throws IOException {
OaSchemaApi api = getDbApi("public-GestaoHospital-original-20290410.json")
.setIdResolver(new OaSchemaIdResolver().setIdName("id"));
String mermaid = new MermaidWriter(api.getDbSchema()).getMermaid();
String mermaid = new MermaidWriter(api.getSchema()).getMermaid();
assertModelMermaid("public-GestaoHospital-original-20290410.md", mermaid);
}

Expand All @@ -84,7 +84,7 @@ public void testMarket() throws IOException {
OaSchemaApi api = getDbApi("public-market-emb-json-20220927.json");
//no usa de momento el resolver hasta que se solucione el caso de array item que tiene una fk
//api.setIdResolver(new OaIdResolver().setIdName("id"));
TdSchema schema = api.getDbSchema();
TdSchema schema = api.getSchema();
assertModel("public-market-emb-json-20220927.txt", schema);
assertEquals("WARN Open Api schema for LinkRelation does not have any property, generated entity will be empty\n"
+ "WARN Open Api schema for Link_rel_xt does not have any property, generated entity will be empty\n"
Expand All @@ -111,7 +111,7 @@ public void testMarket() throws IOException {
@Test
public void testMarketMermaid() throws IOException {
OaSchemaApi api = getDbApi("public-market-emb-json-20220927.json");
String mermaid = new MermaidWriter(api.getDbSchema()).getMermaid();
String mermaid = new MermaidWriter(api.getSchema()).getMermaid();
assertModelMermaid("public-market-emb-json-20220927.md", mermaid);
}

Expand All @@ -120,7 +120,7 @@ public void testMarketMermaid() throws IOException {
@Test
public void testRestApiExample() throws IOException {
OaSchemaApi api = getDbApi("public-rest-api-example-original.json");
TdSchema schema = api.getDbSchema();
TdSchema schema = api.getSchema();
assertModel("public-rest-api-example-original.txt", schema);
// Aparecen dos problemas diferentes:
// 1- El controlador devuelve Iterable&lt;Item&gt; para getAll(), por lo que OpenApi no lo reconoce,
Expand Down

0 comments on commit 7c0dc30

Please sign in to comment.