mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2026-01-08 05:26:19 +00:00
* WIP * amend * Fixes #4977 Add APIs for adding custom fields to an existing entity * Fixes #5010 Entity extension - Add support for storing JSON schema compliant extended fields in entities * Fixes #5042 Backend : Add a field to an entity API is failing
This commit is contained in:
parent
372bc340c7
commit
b407de3080
@ -366,7 +366,7 @@ public class TypeResource extends EntityResource<Type, TypeRepository> {
|
||||
@Context UriInfo uriInfo,
|
||||
@Context SecurityContext securityContext,
|
||||
@Parameter(description = "Type Id", schema = @Schema(type = "string")) @PathParam("id") String id,
|
||||
CustomField field)
|
||||
@Valid CustomField field)
|
||||
throws IOException {
|
||||
SecurityUtil.authorizeAdmin(authorizer, securityContext, ADMIN | BOT);
|
||||
PutResponse<Type> response = dao.addCustomField(uriInfo, securityContext.getUserPrincipal().getName(), id, field);
|
||||
|
||||
@ -12,7 +12,7 @@
|
||||
"$ref": "../../../type/basic.json#/definitions/entityName"
|
||||
},
|
||||
"displayName": {
|
||||
"description": "Display Name that identifies this ingeestion pipeline.",
|
||||
"description": "Display Name that identifies this ingestion pipeline.",
|
||||
"type": "string"
|
||||
},
|
||||
"description": {
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
"$id": "https://open-metadata.org/schema/entity/data/location.json",
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"title": "Location",
|
||||
"description": "This schema defines the Location entity. A Location can contain the data of a table or group other sublocation together.",
|
||||
"description": "This schema defines the Location entity. A Location can contain the data of a table or group other subLocation together.",
|
||||
"type": "object",
|
||||
"javaType": "org.openmetadata.catalog.entity.data.Location",
|
||||
"javaInterfaces": ["org.openmetadata.catalog.EntityInterface"],
|
||||
|
||||
@ -73,13 +73,13 @@
|
||||
"description": "Optional description of entity.",
|
||||
"$ref": "../type/basic.json#/definitions/markdown"
|
||||
},
|
||||
"category": {
|
||||
"$ref": "#/definitions/category"
|
||||
},
|
||||
"nameSpace": {
|
||||
"description": "Namespace or group to which this type belongs to. For example, some of the field types commonly used can come from `basic` namespace. Some of the entities such as `table`, `database`, etc. come from `data` namespace.",
|
||||
"type": "string",
|
||||
"default": "custom"
|
||||
},
|
||||
"category": {
|
||||
"$ref": "#/definitions/category"
|
||||
"default" : "custom"
|
||||
},
|
||||
"schema": {
|
||||
"description": "JSON schema encoded as string that defines the type. This will be used to validate the type values.",
|
||||
|
||||
@ -106,6 +106,7 @@ import org.openmetadata.catalog.entity.services.ingestionPipelines.IngestionPipe
|
||||
import org.openmetadata.catalog.entity.teams.Role;
|
||||
import org.openmetadata.catalog.entity.teams.Team;
|
||||
import org.openmetadata.catalog.entity.teams.User;
|
||||
import org.openmetadata.catalog.entity.type.Category;
|
||||
import org.openmetadata.catalog.entity.type.CustomField;
|
||||
import org.openmetadata.catalog.exception.CatalogExceptionMessage;
|
||||
import org.openmetadata.catalog.resources.databases.TableResourceTest;
|
||||
@ -1130,7 +1131,7 @@ public abstract class EntityResourceTest<T extends EntityInterface, K extends Cr
|
||||
return;
|
||||
}
|
||||
|
||||
// Add custom fields to the entity
|
||||
// Add valid custom fields to the entity
|
||||
TypeResourceTest typeResourceTest = new TypeResourceTest();
|
||||
INT_TYPE = typeResourceTest.getEntityByName("integer", "", ADMIN_AUTH_HEADERS);
|
||||
STRING_TYPE = typeResourceTest.getEntityByName("string", "", ADMIN_AUTH_HEADERS);
|
||||
@ -1145,6 +1146,19 @@ public abstract class EntityResourceTest<T extends EntityInterface, K extends Cr
|
||||
typeResourceTest.addCustomField(entity.getId(), fieldA, OK, ADMIN_AUTH_HEADERS);
|
||||
typeResourceTest.addCustomField(entity.getId(), fieldB, OK, ADMIN_AUTH_HEADERS);
|
||||
|
||||
// Add invalid custom fields to the entity - custom field has invalid type
|
||||
Type INVALID_TYPE =
|
||||
new Type().withId(UUID.randomUUID()).withName("invalid").withCategory(Category.Field).withSchema("{}");
|
||||
CustomField fieldInvalid =
|
||||
new CustomField()
|
||||
.withName("invalid")
|
||||
.withDescription("invalid")
|
||||
.withFieldType(INVALID_TYPE.getEntityReference());
|
||||
assertResponse(
|
||||
() -> typeResourceTest.addCustomField(entity.getId(), fieldInvalid, OK, ADMIN_AUTH_HEADERS),
|
||||
NOT_FOUND,
|
||||
CatalogExceptionMessage.entityNotFound(Entity.TYPE, INVALID_TYPE.getId()));
|
||||
|
||||
// Now create an entity with custom field
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
ObjectNode jsonNode = mapper.createObjectNode();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user