diff --git a/README.md b/README.md index fe23746..9710d51 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,14 @@ # brapi-schema-tools -Tools used to manipulate, extend, convert, and modify the BrAPI Specification documents +Tools used to manipulate, extend, convert, and modify the BrAPI Specification documents. + +Only the [Java based tools](java/README.md) are available at the moment. + +These consist of a Command Line Interface (CLI) that can generate OpenAPI Specification or +GraphQL Schema from the BrAPI JSON Schema. + +## BrAPI JSON Schema +The BrAPI JSON Schema is a new way to define the Data and Query model for BrAPI using JSON Schema. + +The approach is experimental, but it is likely to be supported in a future release of BrAPI. +PLease go to the 'data-model-separation' branch of BrAPI to see the JSON Schema. +* https://github.com/plantbreeding/BrAPI/tree/data-model-separation/Specification/BrAPI-Schema \ No newline at end of file diff --git a/java/README.md b/java/README.md index 8ad2940..a3226b7 100644 --- a/java/README.md +++ b/java/README.md @@ -1,10 +1,34 @@ -# BrAPI Schema Tools +# BrAPI Schema Tools - Java -BrAPI Schema Tools generates and view the BrAPI Specification +The Java BrAPI Schema Tools generates OpenAPI Specification or GraphQL Schema generation. +There is also a basic spring application that allow you to view the BrAPI Specification. -Here you find the following modules +## Quick Start + +1. Download the Command Line Interface (CLI) from the + [Releases](https://github.com/plantbreeding/brapi-schema-tools/releases) page +2. Run the application on your terminal + * In windows + + ```powershell + BrAPITools + ``` + + * In Linux or macOS + + ```shell + BrAPITools + ``` + +## For developers +For more control over the OpenAPI Specification or GraphQL Schema generation or to +contribute, please contact the developers by creating a +[GitHub issue](https://github.com/plantbreeding/brapi-schema-tools/issues) or look directly at the +code + +The Java BrAPI Schema Tools consists of 4 modules: * [application](application/README.md) - A spring application that allow you to view the generated specification -* buildSrc- Defines the plugins use by the gradle +* buildSrc - Defines the plugins use by the gradle * [cli](cli/README.md) - The command line tool that makes use of the core module -* [core](core/README.md) - The core schema tools +* [core](core/README.md) - The core schema tools for OpenAPI Specification or GraphQL Schema generation diff --git a/java/application/src/main/resources/application.properties b/java/application/src/main/resources/application.properties index e761efc..70af596 100644 --- a/java/application/src/main/resources/application.properties +++ b/java/application/src/main/resources/application.properties @@ -1,3 +1,4 @@ management.endpoints.web.exposure.include=health,metrics,info spring.graphql.schema.printer.enabled=true -spring.graphql.graphiql.enabled=true \ No newline at end of file +spring.graphql.graphiql.enabled=true +server.port=8081 \ No newline at end of file diff --git a/java/cli/src/main/java/org/brapi/schematools/cli/GenerateSubCommand.java b/java/cli/src/main/java/org/brapi/schematools/cli/GenerateSubCommand.java index afe3974..85a4ed1 100644 --- a/java/cli/src/main/java/org/brapi/schematools/cli/GenerateSubCommand.java +++ b/java/cli/src/main/java/org/brapi/schematools/cli/GenerateSubCommand.java @@ -105,7 +105,7 @@ private void outputIntrospectionSchema(GraphQLSchema schema) { } private void printGraphQLSchemaErrors(Response response) { - System.err.println("There were errors generating the GraphQL Schema:"); + System.err.printf("There were %d errors generating the GraphQL Schema:%n", response.getAllErrors().size()); response.getAllErrors().forEach(this::printError); } diff --git a/java/core/src/main/java/org/brapi/schematools/core/brapischema/BrAPISchemaReader.java b/java/core/src/main/java/org/brapi/schematools/core/brapischema/BrAPISchemaReader.java index d73ec41..cb0ffbc 100644 --- a/java/core/src/main/java/org/brapi/schematools/core/brapischema/BrAPISchemaReader.java +++ b/java/core/src/main/java/org/brapi/schematools/core/brapischema/BrAPISchemaReader.java @@ -67,7 +67,7 @@ public BrAPISchemaReader() { */ public Response> readDirectories(Path schemaDirectory) throws BrAPISchemaReaderException { try { - return dereferenceAndValidate(find(schemaDirectory, 3, this::schemaPathMatcher).flatMap(this::createBrAPISchemas).collect(Response.toList())) ; + return dereferenceAndValidate(find(schemaDirectory, 3, this::schemaPathMatcher).map(this::createBrAPISchemas).collect(Response.mergeLists())) ; } catch (RuntimeException | IOException e) { throw new BrAPISchemaReaderException(e); } @@ -85,7 +85,7 @@ public Response> readDirectories(Path schemaDirectory) throws B */ public Response readSchema(Path schemaPath, String module) throws BrAPISchemaReaderException { try { - return createBrAPISchemas(schemaPath, module).collect(Response.toList()).mapResult(list -> list.get(0)) ; + return createBrAPISchemas(schemaPath, module).mapResult(list -> list.get(0)) ; } catch (RuntimeException e) { throw new BrAPISchemaReaderException(e); } @@ -104,14 +104,13 @@ public Response readSchema(Path schemaPath, String module) throws Br */ public Response readSchema(Path path, String schema, String module) throws BrAPISchemaReaderException { try { - return createBrAPISchemas(path, objectMapper.readTree(schema), module).collect(Response.toList()).mapResult(list -> list.get(0)) ; + return createBrAPISchemas(path, objectMapper.readTree(schema), module).mapResult(list -> list.get(0)) ; } catch (RuntimeException| JsonProcessingException e) { throw new BrAPISchemaReaderException(String.format("Can not read schema at '%s' in module '%s' from '%s', due to '%s'", path, module, schema, e.getMessage()), e); } } private Response> dereferenceAndValidate(Response> types) { - return types.mapResult(this::dereference).mapResultToResponse(this::validate) ; } @@ -123,13 +122,14 @@ private List dereference(List types) { types.forEach(type -> { if (type instanceof BrAPIAllOfType brAPIAllOfType) { - brAPIClasses.add(BrAPIObjectType.builder(). - name(brAPIAllOfType.getName()). - description(brAPIAllOfType.getDescription()). - module(brAPIAllOfType.getModule()). - properties(extractProperties(new ArrayList<>(), brAPIAllOfType, typeMap)).build()) ; + brAPIClasses.add(BrAPIObjectType.builder() + .name(brAPIAllOfType.getName()) + .description(brAPIAllOfType.getDescription()) + .module(brAPIAllOfType.getModule()) + .metadata(brAPIAllOfType.getMetadata() != null ? brAPIAllOfType.getMetadata().toBuilder().build() : null) + .properties(extractProperties(new ArrayList<>(), brAPIAllOfType, typeMap)).build()); } else { - brAPIClasses.add(type) ; + brAPIClasses.add(type); } }); @@ -210,7 +210,7 @@ private List extractProperties(List pr return properties ; } - private Stream> createBrAPISchemas(Path path) { + private Response> createBrAPISchemas(Path path) { return createBrAPISchemas(path, findModule(path)); } @@ -220,15 +220,19 @@ private String findModule(Path path) { return module != null && COMMON_MODULES.contains(module) ? null : module; } - private Stream> createBrAPISchemas(Path path, String module) { - JsonSchema schema = factory.getSchema(path.toUri()); + private Response> createBrAPISchemas(Path path, String module) { + try { + JsonSchema schema = factory.getSchema(path.toUri()); - JsonNode json = schema.getSchemaNode(); + JsonNode json = schema.getSchemaNode(); - return createBrAPISchemas(path, json, module); + return createBrAPISchemas(path, json, module); + } catch (RuntimeException e) { + return Response.fail(Response.ErrorType.VALIDATION, String.format("Can not read schemas from for module '%s' from path '%s' due to '%s'", module, path, e.getMessage())) ; + } } - private Stream> createBrAPISchemas(Path path, JsonNode json, String module) { + private Response> createBrAPISchemas(Path path, JsonNode json, String module) { JsonNode defs = json.get("$defs"); if (defs != null) { @@ -239,7 +243,7 @@ private Stream> createBrAPISchemas(Path path, JsonNode json return Stream.generate(() -> null) .takeWhile(x -> iterator.hasNext()) - .map(n -> iterator.next()).map(entry -> createBrAPIClass(path, entry.getValue(), entry.getKey(), module)); + .map(n -> iterator.next()).map(entry -> createBrAPIClass(path, entry.getValue(), entry.getKey(), module)).collect(Response.toList()); } private Response createBrAPIClass(Path path, JsonNode jsonNode, String fallbackName, String module) { @@ -379,15 +383,15 @@ private Response createObjectType(Path path, JsonNode jsonNode, Strin List properties = new ArrayList<>(); return Response.empty(). - mapOnCondition(jsonNode.has("additionalProperties"), () -> findChildNode(jsonNode, "additionalProperties", false). + mapOnCondition(jsonNode.has("additionalProperties"), () -> findChildNode(jsonNode, "additionalProperties", true). mapResultToResponse(additionalPropertiesNode -> createProperty(path, additionalPropertiesNode, "additionalProperties", module, required.contains("additionalProperties")).onSuccessDoWithResult(properties::add))). - mapOnCondition(jsonNode.has("properties"), () -> findChildNode(jsonNode, "properties", false). + mapOnCondition(jsonNode.has("properties"), () -> findChildNode(jsonNode, "properties", true). mapResult(JsonNode::fields). mapResultToResponse(fields -> createProperties(path, fields, module, required)). onSuccessDoWithResult(properties::addAll)). onSuccessDo(() -> builder.properties(properties)). - mapOnCondition(jsonNode.has("brapi-metadata"), () -> findChildNode(jsonNode, "brapi-metadata", false). + mapOnCondition(jsonNode.has("brapi-metadata"), () -> findChildNode(jsonNode, "brapi-metadata", true). mapResultToResponse(this::parseMetadata).onSuccessDoWithResult(builder::metadata)). map(() -> success(builder.build())); } @@ -441,6 +445,8 @@ private Response createAllOfType(Path path, JsonNode jsonNode, String mapResult(this::childNodes). mapResultToResponse(childNodes -> childNodes.mapResultToResponse(nodes -> createAllTypes(path, nodes, name, module))). onSuccessDoWithResult(builder::allTypes). + mapOnCondition(jsonNode.has("brapi-metadata"), () -> findChildNode(jsonNode, "brapi-metadata", true). + mapResultToResponse(this::parseMetadata).onSuccessDoWithResult(builder::metadata)). map(() -> success(builder.build())); } @@ -464,6 +470,8 @@ private Response createOneOfType(Path path, JsonNode jsonNode, String mapResult(this::childNodes). mapResultToResponse(childNodes -> childNodes.mapResultToResponse(nodes -> createPossibleTypes(path, nodes, name, module))). onSuccessDoWithResult(builder::possibleTypes). + mapOnCondition(jsonNode.has("brapi-metadata"), () -> findChildNode(jsonNode, "brapi-metadata", true). + mapResultToResponse(this::parseMetadata).onSuccessDoWithResult(builder::metadata)). map(() -> success(builder.build())); } @@ -487,6 +495,8 @@ private Response createEnumType(JsonNode jsonNode, String name, Strin return findStringList(jsonNode, "enum", true). mapResultToResponse(strings -> createEnumValues(strings, type)). onSuccessDoWithResult(builder::values). + mapOnCondition(jsonNode.has("brapi-metadata"), () -> findChildNode(jsonNode, "brapi-metadata", true). + mapResultToResponse(this::parseMetadata).onSuccessDoWithResult(builder::metadata)). map(() -> success(builder.build())); } diff --git a/java/core/src/main/java/org/brapi/schematools/core/graphql/GraphQLGenerator.java b/java/core/src/main/java/org/brapi/schematools/core/graphql/GraphQLGenerator.java index 524e219..c74be17 100644 --- a/java/core/src/main/java/org/brapi/schematools/core/graphql/GraphQLGenerator.java +++ b/java/core/src/main/java/org/brapi/schematools/core/graphql/GraphQLGenerator.java @@ -11,12 +11,15 @@ import org.brapi.schematools.core.graphql.options.GraphQLGeneratorOptions; import org.brapi.schematools.core.model.*; import org.brapi.schematools.core.response.Response; -import org.brapi.schematools.core.utils.StringUtils; import java.nio.file.Path; -import java.util.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; import java.util.function.Function; import java.util.stream.Collectors; +import java.util.stream.Stream; import static graphql.Scalars.GraphQLBoolean; import static graphql.Scalars.GraphQLFloat; @@ -30,9 +33,6 @@ import static org.brapi.schematools.core.response.Response.fail; import static org.brapi.schematools.core.response.Response.success; import static org.brapi.schematools.core.utils.StringUtils.makeValidName; -import static org.brapi.schematools.core.utils.StringUtils.toParameterCase; -import static org.brapi.schematools.core.utils.StringUtils.toPlural; -import static org.brapi.schematools.core.utils.StringUtils.toSentenceCase; /** * Generates a GraphQL schema from a BrAPI Json Schema. @@ -97,16 +97,12 @@ private static class Generator { private final GraphQLGeneratorOptions options; private final GraphQLGeneratorMetadata metadata; private final Map brAPISchemas; - private final Map objectOutputTypes; private final Map unionTypes; private final Map enumTypes; - private final Map inputObjectTypes; - private final Set additionalTypes; - + private final Map inputTypes; private final GraphQLCodeRegistry.Builder codeRegistry = GraphQLCodeRegistry.newCodeRegistry(); - public Generator(GraphQLGeneratorOptions options, GraphQLGeneratorMetadata metadata, List brAPISchemas) { this.options = options; this.metadata = metadata; @@ -114,60 +110,82 @@ public Generator(GraphQLGeneratorOptions options, GraphQLGeneratorMetadata metad objectOutputTypes = new HashMap<>(); unionTypes = new HashMap<>(); enumTypes = new HashMap<>(); - inputObjectTypes = new HashMap<>(); - additionalTypes = new HashSet<>(); + inputTypes = new HashMap<>(); } public Response generate() { return brAPISchemas.values().stream(). - filter(this::isInputType). - map(this::createInputObjectType).collect(Response.toList()). - onSuccessDoWithResult(additionalTypes::addAll). - merge(() -> brAPISchemas.values().stream(). filter(this::isNonPrimaryModel). map(this::createOutputType). collect(Response.toList()). - onSuccessDoWithResult(additionalTypes::addAll)). + mapOnCondition(options.isGeneratingCreateMutation() || options.isGeneratingUpdateMutation(), + () -> brAPISchemas.values().stream(). + filter(this::isGeneratingInputTypeForMutation). + map(this::createInputObjectTypeForModel). + collect(Response.toList())). + mapOnCondition(options.isGeneratingListQueries(), + () -> brAPISchemas.values().stream(). + filter(this::isGeneratingInputTypeForListQuery). + map(this::createInputObjectTypeForListQuery). + collect(Response.toList())). + mapOnCondition(options.isGeneratingSearchQueries(), + () -> brAPISchemas.values().stream(). + filter(this::isGeneratingInputTypeForSearchQuery). + map(this::createInputObjectTypeForSearchQuery). + collect(Response.toList())). map(() -> brAPISchemas.values().stream(). filter(this::isPrimaryModel). map(type -> createObjectType((BrAPIObjectType) type)). - collect(Response.toList()). - onSuccessDoWithResult(additionalTypes::addAll)). + collect(Response.toList())). mapResultToResponse(this::createSchema); } - private boolean isInputType(BrAPIClass type) { - return type instanceof BrAPIObjectType && type.getMetadata() != null && type.getMetadata().isRequest() ; + private boolean isGeneratingInputTypeForListQuery(BrAPIClass brAPIClass) { + return isPrimaryModel(brAPIClass) && + (options.isGeneratingListQueryFor(brAPIClass.getName()) && + !inputTypes.containsKey(options.getQueryInputTypeNameFor(brAPIClass)) && + options.getQueryType().getListQuery().hasInputFor(brAPIClass)) ; + } + + private boolean isGeneratingInputTypeForSearchQuery(BrAPIClass brAPIClass) { + return isPrimaryModel(brAPIClass) && + (options.isGeneratingSearchQueryFor(brAPIClass.getName()) && + !inputTypes.containsKey(options.getQueryInputTypeNameFor(brAPIClass)) && + options.getQueryType().getSearchQuery().hasInputFor(brAPIClass)) ; + } + + private boolean isGeneratingInputTypeForMutation(BrAPIClass brAPIClass) { + return isPrimaryModel(brAPIClass) && (options.isGeneratingCreateMutationFor(brAPIClass.getName()) || options.isGeneratingDeleteMutationFor(brAPIClass.getName())) ; + } + + private boolean isNotInputType(BrAPIClass type) { + return !(type instanceof BrAPIObjectType) || type.getMetadata() == null || !type.getMetadata().isRequest(); } private boolean isPrimaryModel(BrAPIClass type) { - return !isInputType(type) && type.getMetadata() != null && type.getMetadata().isPrimaryModel() ; + return isNotInputType(type) && type.getMetadata() != null && type.getMetadata().isPrimaryModel() ; } private boolean isNonPrimaryModel(BrAPIClass type) { - return !isInputType(type) && (type.getMetadata() == null || !type.getMetadata().isPrimaryModel()) ; + return isNotInputType(type) && (type.getMetadata() == null || !type.getMetadata().isPrimaryModel()) ; } - private Response createSchema(List types) { - + private Response createSchema(List primaryTypes) { GraphQLSchema.Builder builder = GraphQLSchema.newSchema(); if (options.isGeneratingQueryType()) { GraphQLObjectType.Builder query = newObject().name(options.getQueryType().getName()); if (options.isGeneratingSingleQueries()) { - types.stream().filter(type -> options.getQueryType().getSingleQuery().getGeneratingFor(). - getOrDefault(type.getName(), options.getQueryType().getSingleQuery().isGenerating())).map(this::generateSingleGraphQLQuery).forEach(query::field); + primaryTypes.stream().filter(type -> options.getQueryType().getSingleQuery().isGeneratingFor(type.getName())).map(this::generateSingleGraphQLQuery).forEach(query::field); } if (options.isGeneratingListQueries()) { - types.stream().filter(type -> options.getQueryType().getListQuery().getGeneratingFor(). - getOrDefault(type.getName(), options.getQueryType().getListQuery().isGenerating())).map(this::generateListGraphQLQuery).forEach(query::field); + primaryTypes.stream().filter(type -> options.getQueryType().getListQuery().isGeneratingFor(type.getName())).map(this::generateListGraphQLQuery).forEach(query::field); } if (options.isGeneratingSearchQueries()) { - types.stream().filter(type -> options.getQueryType().getSearchQuery().getGeneratingFor(). - getOrDefault(type.getName(), options.getQueryType().getSearchQuery().isGenerating())).map(this::generateSearchGraphQLQuery).forEach(query::field); + primaryTypes.stream().filter(type -> options.getQueryType().getSearchQuery().isGeneratingFor(type.getName())).map(this::generateSearchGraphQLQuery).forEach(query::field); } builder.query(query); @@ -176,19 +194,27 @@ private Response createSchema(List types) { if (options.isGeneratingMutationType()) { GraphQLObjectType.Builder mutation = newObject().name(options.getMutationType().getName()); - types.stream().filter(type -> options.getMutationType().getGeneratingFor(). - getOrDefault(type.getName(), options.getMutationType().isGenerating())).map(this::generateSingleGraphQLMutation).forEach(mutation::field); + primaryTypes.stream().filter(type -> options.isGeneratingCreateMutationFor(type.getName())) + .map(this::generateCreateGraphQLMutation).forEach(mutation::field); + + primaryTypes.stream().filter(type -> options.isGeneratingUpdateMutationFor(type.getName())) + .map(this::generateUpdateGraphQLMutation).forEach(mutation::field); + + primaryTypes.stream().filter(type -> options.isGeneratingDeleteMutationFor(type.getName())) + .map(this::generateDeleteGraphQLMutation).forEach(mutation::field); builder.mutation(mutation); } - if (options.isGeneratingListQueries() && - (options.getQueryType().getListQuery().isPagedDefault() || options.getQueryType().getListQuery().getPaged().values().stream().anyMatch(paged -> paged))) { - additionalTypes.add(createPageInputType()); - additionalTypes.add(createPageType()); - } + objectOutputTypes.values().forEach(builder::additionalType); + enumTypes.values().forEach(builder::additionalType); + inputTypes.values().forEach(builder::additionalType); + unionTypes.values().forEach(builder::additionalType); - builder.additionalTypes(additionalTypes); + if (options.isGeneratingListQueries() && options.getQueryType().getListQuery().hasPaging() ) { + builder.additionalType(createPageInputType()); + builder.additionalType(createPageType()); + } unionTypes.values().forEach(graphQLType -> codeRegistry.typeResolver(graphQLType, new UnionTypeResolver(graphQLType))); @@ -208,9 +234,9 @@ private Response createOutputType(BrAPIType type) { } else if (type instanceof BrAPIOneOfType) { return createUnionOutputType((BrAPIOneOfType) type).mapResult(t -> t); } else if (type instanceof BrAPIArrayType) { - return createListType((BrAPIArrayType) type).mapResult(t -> t); + return createOutputListType((BrAPIArrayType) type).mapResult(t -> t); } else if (type instanceof BrAPIReferenceType) { - return createReferenceType((BrAPIReferenceType) type).mapResult(t -> t); + return createOutputReferenceType((BrAPIReferenceType) type).mapResult(t -> t); } else if (type instanceof BrAPIEnumType) { return createEnumType((BrAPIEnumType) type).mapResult(t -> t); } else if (type instanceof BrAPIPrimitiveType) { @@ -220,11 +246,11 @@ private Response createOutputType(BrAPIType type) { return Response.fail(Response.ErrorType.VALIDATION, String.format("Unknown output type '%s'", type.getName())); } - private Response createReferenceType(BrAPIReferenceType type) { + private Response createOutputReferenceType(BrAPIReferenceType type) { return success(GraphQLTypeReference.typeRef(type.getName())); } - private Response createListType(BrAPIArrayType type) { + private Response createOutputListType(BrAPIArrayType type) { return createOutputType(type.getItems()).mapResult(GraphQLList::list); } @@ -256,20 +282,65 @@ private Response createFieldDefinition(BrAPIObjectProper map(() -> success(builder.build())); } - private Response createInputObjectType(BrAPIClass type) { + private Response createInputReferenceType(BrAPIReferenceType type) { + BrAPIClass referencedSchema = this.brAPISchemas.get(type.getName()); - if (type instanceof BrAPIObjectType brAPIObjectType) { + if (referencedSchema != null && !(referencedSchema instanceof BrAPIEnumType)) { + String inputTypeName = options.getInput().getTypeNameFor(referencedSchema) ; + + if (isNotInputType(referencedSchema)) { + return createInputObjectTypeForModel(referencedSchema). + withResult(GraphQLTypeReference.typeRef(inputTypeName)) ; + } - String queryName = toPlural(toParameterCase(brAPIObjectType.getName().substring(0, brAPIObjectType.getName().length() - 7))); + return success(GraphQLTypeReference.typeRef(inputTypeName)) ; + } - String name = String.format(options.getQueryType().getListQuery().getInputTypeNameFormat(), StringUtils.toSentenceCase(queryName)); + return success(GraphQLTypeReference.typeRef(type.getName())); + } + + private Response createInputListType(BrAPIArrayType type) { + return createInputType(type.getItems()).mapResult(GraphQLList::list); + } + + private Response createInputObjectTypeForModel(BrAPIClass type) { + return createInputObjectType(options.getInput().getTypeNameFor(type), type) ; + } + + private Response createInputObjectTypeForListQuery(BrAPIClass type) { + return createInputTypeFromClass(options.getQueryInputTypeNameFor(type), type) ; + } - GraphQLInputObjectType existingType = inputObjectTypes.get(name); + private Response createInputObjectTypeForSearchQuery(BrAPIClass type) { + return createInputTypeFromClass(options.getQueryInputTypeNameFor(type), type) ; + } - if (existingType != null) { - return success(existingType); + private Response createInputTypeFromClass(String name, BrAPIClass type) { + if (type instanceof BrAPIObjectType brAPIObjectType) { + if (type.getName().endsWith("Request")) { + return createInputObjectType(options.getInput().getTypeNameForQuery( + options.getQueryType().getListQuery().getNameFor(options.getPluralFor(type.getName().substring(0, type.getName().length() - 7)))), type) ; + } else { + return createInputObjectType(name, brAPIObjectType).mapResult(t -> t); } + } else if (type instanceof BrAPIEnumType brAPIEnumType) { + return createEnumType(brAPIEnumType).mapResult(t -> t); + } else { + return Response.fail(Response.ErrorType.VALIDATION, String.format("Input object '%s' must be BrAPIObjectType or BrAPIEnumType but was '%s'", type.getName(), type.getClass().getSimpleName())) ; + } + } + + private Response createInputObjectType(String name, BrAPIClass type) { + GraphQLNamedInputType existingType = inputTypes.get(name); + + if (existingType != null) { + return success(existingType); + } else { + addInputObjectType(GraphQLTypeReference.typeRef(name)); + } + + if (type instanceof BrAPIObjectType brAPIObjectType) { GraphQLInputObjectType.Builder builder = newInputObject(). name(name). description(brAPIObjectType.getDescription()); @@ -277,26 +348,42 @@ private Response createInputObjectType(BrAPIClass type) return brAPIObjectType.getProperties().stream().map(this::createInputObjectField).collect(Response.toList()). onSuccessDoWithResult(builder::fields). map(() -> addInputObjectType(builder.build())); + } else if (type instanceof BrAPIOneOfType brAPIOneOfType) { + GraphQLInputObjectType.Builder builder = newInputObject(). + name(name). + description(brAPIOneOfType.getDescription()); + + return brAPIOneOfType.getPossibleTypes().stream().flatMap(this::extractProperties).map(this::createInputObjectField).collect(Response.toList()). + onSuccessDoWithResult(builder::fields). + map(() -> addInputObjectType(builder.build())); } else { - return Response.fail(Response.ErrorType.VALIDATION, String.format("Input object '%s' must be BrAPIObjectType but was '%s'", type.getName(), type.getClass().getSimpleName())) ; + return Response.fail(Response.ErrorType.VALIDATION, String.format("Input object '%s' must be BrAPIObjectType or BrAPIOneOfType but was '%s'", type.getName(), type.getClass().getSimpleName())) ; + } + } + + private Stream extractProperties(BrAPIType brAPIType) { + if (brAPIType instanceof BrAPIObjectType brAPIObjectType) { + return brAPIObjectType.getProperties().stream() ; + } else { + return Stream.empty() ; } } private Response createInputType(BrAPIType type) { if (type instanceof BrAPIObjectType) { - return createInputObjectType((BrAPIObjectType) type).mapResult(t -> t); + return createInputObjectTypeForModel((BrAPIObjectType) type).mapResult(t -> t); } else if (type instanceof BrAPIArrayType) { - return createListType((BrAPIArrayType) type).mapResult(t -> t); + return createInputListType((BrAPIArrayType) type).mapResult(t -> t); } else if (type instanceof BrAPIReferenceType) { - return createReferenceType((BrAPIReferenceType) type).mapResult(t -> t); + return createInputReferenceType((BrAPIReferenceType) type).mapResult(t -> t); } else if (type instanceof BrAPIEnumType) { return createEnumType((BrAPIEnumType) type).mapResult(t -> t); } else if (type instanceof BrAPIPrimitiveType) { return createScalarType((BrAPIPrimitiveType) type).mapResult(t -> t); } - return Response.fail(Response.ErrorType.VALIDATION, String.format("Unknown input type '%s'", type.getName())); + return Response.fail(Response.ErrorType.VALIDATION, String.format("Unknown input type '%s' for '%s'", type.getClass().getSimpleName(), type.getName())); } private Response createInputObjectField(BrAPIObjectProperty property) { @@ -390,8 +477,8 @@ private Response addEnumType(GraphQLEnumType type) { return success(type); } - private Response addInputObjectType(GraphQLInputObjectType type) { - inputObjectTypes.put(type.getName(), type); + private Response addInputObjectType(GraphQLNamedInputType type) { + inputTypes.put(type.getName(), type); return success(type); } @@ -399,14 +486,14 @@ private Response addInputObjectType(GraphQLInputObjectTy private GraphQLFieldDefinition.Builder generateSingleGraphQLQuery(GraphQLObjectType type) { return GraphQLFieldDefinition.newFieldDefinition(). - name(toParameterCase(type.getName())). + name(options.getSingleQueryNameFor(type.getName())). description(createSingleQueryDescription(type)). arguments(createSingleQueryArguments(type)). type(GraphQLTypeReference.typeRef(type.getName())); } private String createSingleQueryDescription(GraphQLObjectType type) { - return String.format(options.getQueryType().getSingleQuery().getDescriptionFormat(), type.getName()); + return options.getQueryType().getSingleQuery().getDescriptionFor(type.getName()); } private List createSingleQueryArguments(GraphQLObjectType type) { @@ -414,7 +501,7 @@ private List createSingleQueryArguments(GraphQLObjectType type) List arguments = new ArrayList<>(); arguments.add(GraphQLArgument.newArgument(). - name(String.format(options.getIds().getNameFormat(), StringUtils.toParameterCase(type.getName()))). + name(options.getIds().getNameFor(type.getName())). type(options.isUsingIDType() ? GraphQLID : GraphQLString). build()); @@ -429,34 +516,38 @@ private List createSingleQueryArguments(GraphQLObjectType type) } private GraphQLFieldDefinition.Builder generateListGraphQLQuery(GraphQLObjectType type) { + String queryName = options.getListQueryNameFor(type.getName()) ; - String queryName = toPlural(toParameterCase(type.getName())); - - boolean paged = options.getQueryType().getListQuery().getPaged().containsKey(type.getName()) ? - options.getQueryType().getListQuery().getPaged().get(type.getName()) : options.getQueryType().getListQuery().isPagedDefault(); + boolean paged = options.getQueryType().getListQuery().isPagedFor(type.getName()); + boolean hasInput = options.getQueryType().getListQuery().hasInputFor(type.getName()) ; return GraphQLFieldDefinition.newFieldDefinition(). name(queryName). description(createListQueryDescription(type)). - arguments(createListQueryArguments(queryName, paged, type)). + arguments(createListQueryArguments(paged, hasInput, type)). type(createListResponse(queryName, paged, type)); } private String createListQueryDescription(GraphQLObjectType type) { - return String.format(options.getQueryType().getListQuery().getDescriptionFormat(), type.getName()); + return options.getQueryType().getListQuery().getDescriptionFor(type.getName()); } - private List createListQueryArguments(String queryName, boolean paged, GraphQLObjectType type) { + private List createListQueryArguments(boolean paged,boolean hasInput, GraphQLObjectType type) { List arguments = new ArrayList<>(); - boolean hasInput = options.getQueryType().getListQuery().getInput().getOrDefault(type.getName(), true); + String inputTypeName = options.getQueryInputTypeNameFor(type.getName()) ; if (hasInput) { arguments.add(GraphQLArgument.newArgument(). - name(options.getQueryType().getListQuery().getInputNameFormat() != null ? - String.format(options.getQueryType().getListQuery().getInputNameFormat(), StringUtils.toParameterCase(type.getName())) : - options.getQueryType().getListQuery().getInputName()). - type(GraphQLTypeReference.typeRef(String.format(options.getQueryType().getListQuery().getInputTypeNameFormat(), StringUtils.toSentenceCase(queryName)))). + name(options.getInput().getNameFor(type.getName())). + type(GraphQLTypeReference.typeRef(inputTypeName)). + build()); + } + + if (options.getQueryType().isPartitionedByCrop() && !hasField(inputTypeName, "commonCropName")) { + arguments.add(GraphQLArgument.newArgument(). + name("commonCropName"). + type(GraphQLString). build()); } @@ -470,9 +561,19 @@ private List createListQueryArguments(String queryName, boolean return arguments; } + private boolean hasField(String typeName, String fieldName) { + GraphQLNamedInputType type = this.inputTypes.get(typeName); + + if (type instanceof GraphQLInputObjectType graphQLInputObjectType) { + return graphQLInputObjectType.getField(fieldName) == null ; + } + + return false ; + } + private GraphQLOutputType createListResponse(String queryName, boolean paged, GraphQLObjectType type) { GraphQLObjectType.Builder builder = newObject(). - name(String.format(options.getQueryType().getListQuery().getResponseTypeNameFormat(), toSentenceCase(queryName))). + name(String.format(options.getQueryType().getListQuery().getResponseTypeNameForQuery(queryName))). field(createListDataField(type)); if (paged) { @@ -509,21 +610,148 @@ private GraphQLType createPageType() { } private GraphQLFieldDefinition.Builder generateSearchGraphQLQuery(GraphQLObjectType type) { + String queryName = options.getSearchQueryNameFor(type.getName()) ; + + return GraphQLFieldDefinition.newFieldDefinition() + .name(queryName) + .description(createSearchQueryDescription(type)) + .arguments(createSearchQueryArguments(type)) + .type(creatSearchResponse(queryName, type)); + } - String queryName = toPlural(toSentenceCase(type.getName())); + private String createSearchQueryDescription(GraphQLObjectType type) { + return options.getQueryType().getSearchQuery().getDescriptionFor(type.getName()); + } - boolean paged = options.getQueryType().getListQuery().getPaged().getOrDefault(type.getName(), options.getQueryType().getListQuery().isPagedDefault()); + private List createSearchQueryArguments(GraphQLObjectType type) { + List arguments = new ArrayList<>(); - return GraphQLFieldDefinition.newFieldDefinition(). - name(toParameterCase(queryName)). - description(createListQueryDescription(type)). - arguments(createListQueryArguments(queryName, paged, type)). - type(createListResponse(queryName, paged, type)); + String inputTypeName = options.getQueryInputTypeNameFor(type.getName()) ; + + arguments.add(GraphQLArgument.newArgument(). + name(options.getInput().getNameFor(type.getName())). + type(GraphQLTypeReference.typeRef(inputTypeName)). + build()); + + if (options.getQueryType().isPartitionedByCrop() && !hasField(inputTypeName, "commonCropName")) { + arguments.add(GraphQLArgument.newArgument(). + name("commonCropName"). + type(GraphQLString). + build()); + } + + return arguments; } - private GraphQLFieldDefinition.Builder generateSingleGraphQLMutation(GraphQLObjectType type) { - return GraphQLFieldDefinition.newFieldDefinition(). - name(toParameterCase(type.getName())); + private GraphQLOutputType creatSearchResponse(String queryName, GraphQLObjectType type) { + GraphQLObjectType.Builder builder = newObject(). + name(String.format(options.getQueryType().getSearchQuery().getResponseTypeNameForQuery(queryName))). + field(GraphQLFieldDefinition.newFieldDefinition(). + name(options.getQueryType().getSearchQuery().getSearchIdFieldName()). + type(GraphQLList.list(GraphQLTypeReference.typeRef(type.getName()))). + build()). + field(createListDataField(type)); + + return builder.build(); + } + + private GraphQLFieldDefinition.Builder generateCreateGraphQLMutation(GraphQLObjectType type) { + return GraphQLFieldDefinition.newFieldDefinition() + .name(options.getCreateMutationNameFor(type.getName())) + .description(createCreateMutationDescription(type)) + .arguments(createCreateMutationArguments(type)) + .type(options.getMutationType().getCreateMutation().isMultiple() ? + GraphQLList.list(GraphQLTypeReference.typeRef(type.getName())) : GraphQLTypeReference.typeRef(type.getName())) ; + } + + private String createCreateMutationDescription(GraphQLObjectType type) { + return options.getMutationType().getCreateMutation().getDescriptionFor(type.getName()); + } + + private List createCreateMutationArguments(GraphQLObjectType type) { + List arguments = new ArrayList<>(); + + String inputTypeName = options.getInput().getTypeNameFor(type.getName()) ; + + arguments.add(GraphQLArgument.newArgument(). + name(options.getInput().getNameFor(type.getName())). + type(options.getMutationType().getCreateMutation().isMultiple() ? + GraphQLList.list(GraphQLTypeReference.typeRef(inputTypeName)) : GraphQLTypeReference.typeRef(inputTypeName)). + build()); + + if (options.getQueryType().isPartitionedByCrop() && !hasField(inputTypeName, "commonCropName")) { + arguments.add(GraphQLArgument.newArgument(). + name("commonCropName"). + type(GraphQLString). + build()); + } + + return arguments; + } + + private GraphQLFieldDefinition.Builder generateUpdateGraphQLMutation(GraphQLObjectType type) { + return GraphQLFieldDefinition.newFieldDefinition() + .name(options.getUpdateMutationNameFor(type.getName())) + .description(createUpdateMutationDescription(type)) + .arguments(createUpdateMutationArguments(type)) + .type(options.getMutationType().getUpdateMutation().isMultiple() ? + GraphQLList.list(GraphQLTypeReference.typeRef(type.getName())) : GraphQLTypeReference.typeRef(type.getName())) ; + } + + private String createUpdateMutationDescription(GraphQLObjectType type) { + return options.getMutationType().getUpdateMutation().getDescriptionFor(type.getName()); + } + + private List createUpdateMutationArguments(GraphQLObjectType type) { + List arguments = new ArrayList<>(); + + String inputTypeName = options.getInput().getTypeNameFor(type.getName()) ; + + arguments.add(GraphQLArgument.newArgument(). + name(options.getInput().getNameFor(type.getName())). + type(options.getMutationType().getCreateMutation().isMultiple() ? + GraphQLList.list(GraphQLTypeReference.typeRef(inputTypeName)) : GraphQLTypeReference.typeRef(inputTypeName)). + build()); + + if (options.getQueryType().isPartitionedByCrop() && !hasField(inputTypeName, "commonCropName")) { + arguments.add(GraphQLArgument.newArgument(). + name("commonCropName"). + type(GraphQLString). + build()); + } + + return arguments; + } + + private GraphQLFieldDefinition.Builder generateDeleteGraphQLMutation(GraphQLObjectType type) { + return GraphQLFieldDefinition.newFieldDefinition() + .name(options.getDeleteMutationNameFor(type.getName())) + .description(createDeleteMutationDescription(type)) + .arguments(createDeleteMutationArguments(type)) + .type(options.getMutationType().getDeleteMutation().isMultiple() ? + GraphQLList.list(GraphQLTypeReference.typeRef(type.getName())) : GraphQLTypeReference.typeRef(type.getName())) ; + } + + private String createDeleteMutationDescription(GraphQLObjectType type) { + return options.getMutationType().getDeleteMutation().getDescriptionFor(type.getName()); + } + + private List createDeleteMutationArguments(GraphQLObjectType type) { + List arguments = new ArrayList<>(); + + arguments.add(GraphQLArgument.newArgument(). + name(options.getIds().getNameFor(type.getName())). + type(options.isUsingIDType() ? GraphQLID : GraphQLString). + build()); + + if (options.getQueryType().isPartitionedByCrop()) { + arguments.add(GraphQLArgument.newArgument(). + name("commonCropName"). + type(GraphQLString). + build()); + } + + return arguments; } } diff --git a/java/core/src/main/java/org/brapi/schematools/core/graphql/options/AbstractGraphQLOptions.java b/java/core/src/main/java/org/brapi/schematools/core/graphql/options/AbstractGraphQLOptions.java new file mode 100644 index 0000000..baf8b6f --- /dev/null +++ b/java/core/src/main/java/org/brapi/schematools/core/graphql/options/AbstractGraphQLOptions.java @@ -0,0 +1,48 @@ +package org.brapi.schematools.core.graphql.options; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.*; +import org.brapi.schematools.core.model.BrAPIType; +import org.brapi.schematools.core.options.AbstractOptions; + +import static org.brapi.schematools.core.utils.StringUtils.toParameterCase; + + +/** + * Provides general options for the generation of Endpoints + */ +@Getter +@Setter +@NoArgsConstructor(access = AccessLevel.PROTECTED) +@AllArgsConstructor(access = AccessLevel.PROTECTED) +public abstract class AbstractGraphQLOptions extends AbstractOptions { + private boolean pluralisingName; + @Getter(AccessLevel.PRIVATE) + private String nameFormat; + + public void validate() { + super.validate(); + assert nameFormat != null : String.format("'nameFormat' option on %s is null", this.getClass().getSimpleName()); + } + + /** + * Gets the name of the query or mutation for a specific primary model + * @param name the name of the primary model + * @return the name of the query or mutation for a specific primary model + */ + @JsonIgnore + public final String getNameFor(@NonNull String name) { + return String.format(nameFormat, nameFormat.startsWith("%s") ? toParameterCase(name) : name) ; + } + + /** + * Gets the name of query or mutation for a specific primary model + * @param type the primary model + * @return the name of the query or mutation for a specific primary model + */ + @JsonIgnore + public final String getNameFor(@NonNull BrAPIType type) { + return getNameFor(type.getName()); + } +} + diff --git a/java/core/src/main/java/org/brapi/schematools/core/graphql/options/AbstractGraphQLQueryOptions.java b/java/core/src/main/java/org/brapi/schematools/core/graphql/options/AbstractGraphQLQueryOptions.java new file mode 100644 index 0000000..0c1f752 --- /dev/null +++ b/java/core/src/main/java/org/brapi/schematools/core/graphql/options/AbstractGraphQLQueryOptions.java @@ -0,0 +1,72 @@ +package org.brapi.schematools.core.graphql.options; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.*; +import org.brapi.schematools.core.model.BrAPIType; + +import java.util.HashMap; +import java.util.Map; + +import static org.brapi.schematools.core.utils.StringUtils.toSentenceCase; + +@Getter +@Setter +@NoArgsConstructor(access = AccessLevel.PROTECTED) +@AllArgsConstructor(access = AccessLevel.PROTECTED) +public class AbstractGraphQLQueryOptions extends AbstractGraphQLOptions { + @Getter(AccessLevel.PRIVATE) + private String responseTypeNameFormat; + + @Getter(AccessLevel.NONE) + @Setter(AccessLevel.PRIVATE) + private Map input = new HashMap<>(); + + public void validate() { + super.validate(); + assert responseTypeNameFormat != null : String.format("'responseTypeNameFormat' option on %s is null", this.getClass().getSimpleName()); + assert input != null : String.format("'input' option on %s is null", this.getClass().getSimpleName()); + } + + /** + * Gets the response type name of the query for a specific primary model + * @param queryName the name of the query + * @return the response type name of the query for a specific primary model + */ + @JsonIgnore + public final String getResponseTypeNameForQuery(@NonNull String queryName) { + return String.format(responseTypeNameFormat, toSentenceCase(queryName)) ; + } + + /** + * Determines if the Query accepts an input object for a specific primary model + * @param name the name of the primary model + * @return true if the Query accepts an input object for a specific primary model, false otherwise + */ + @JsonIgnore + public final boolean hasInputFor(@NonNull String name) { + return input.getOrDefault(name, true) ; + } + + /** + * Determines if the Query accepts an input object for a specific primary model + * @param type the primary model + * @return true if the Query accepts an input object for a specific primary model, false otherwise + */ + @JsonIgnore + public final boolean hasInputFor(@NonNull BrAPIType type) { + return hasInputFor(type.getName()) ; + } + + /** + * Sets if the Query accepts an input object for a specific primary model + * @param name the name of the primary model + * @param hasInput true if the Query accepts an input object for a specific primary model, false otherwise + * @return the options for chaining + */ + @JsonIgnore + public AbstractGraphQLQueryOptions setInputFor(String name, boolean hasInput) { + input.put(name, hasInput) ; + + return this ; + } +} diff --git a/java/core/src/main/java/org/brapi/schematools/core/graphql/options/CreateMutationOptions.java b/java/core/src/main/java/org/brapi/schematools/core/graphql/options/CreateMutationOptions.java new file mode 100644 index 0000000..0741f53 --- /dev/null +++ b/java/core/src/main/java/org/brapi/schematools/core/graphql/options/CreateMutationOptions.java @@ -0,0 +1,18 @@ +package org.brapi.schematools.core.graphql.options; + +import lombok.AccessLevel; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + +/** + * Provides options for the generation of New Mutations + */ +@Getter +@Setter +@NoArgsConstructor(access = AccessLevel.PRIVATE) +@AllArgsConstructor(access = AccessLevel.PRIVATE) +public class CreateMutationOptions extends AbstractGraphQLOptions { + boolean multiple; +} diff --git a/java/core/src/main/java/org/brapi/schematools/core/graphql/options/DeleteMutationOptions.java b/java/core/src/main/java/org/brapi/schematools/core/graphql/options/DeleteMutationOptions.java new file mode 100644 index 0000000..214465b --- /dev/null +++ b/java/core/src/main/java/org/brapi/schematools/core/graphql/options/DeleteMutationOptions.java @@ -0,0 +1,18 @@ +package org.brapi.schematools.core.graphql.options; + +import lombok.AccessLevel; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + +/** + * Provides options for the generation of Delete Mutations + */ +@Getter +@Setter +@NoArgsConstructor(access = AccessLevel.PRIVATE) +@AllArgsConstructor(access = AccessLevel.PRIVATE) +public class DeleteMutationOptions extends AbstractGraphQLOptions { + boolean multiple; +} diff --git a/java/core/src/main/java/org/brapi/schematools/core/graphql/options/GraphQLGeneratorOptions.java b/java/core/src/main/java/org/brapi/schematools/core/graphql/options/GraphQLGeneratorOptions.java index 58e6ee3..7828ff6 100644 --- a/java/core/src/main/java/org/brapi/schematools/core/graphql/options/GraphQLGeneratorOptions.java +++ b/java/core/src/main/java/org/brapi/schematools/core/graphql/options/GraphQLGeneratorOptions.java @@ -1,12 +1,13 @@ package org.brapi.schematools.core.graphql.options; import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; -import graphql.schema.GraphQLScalarType; import lombok.*; +import lombok.experimental.Accessors; import org.brapi.schematools.core.graphql.GraphQLGenerator; +import org.brapi.schematools.core.model.BrAPIType; +import org.brapi.schematools.core.options.AbstractGeneratorOptions; import java.io.IOException; import java.io.InputStream; @@ -18,14 +19,15 @@ */ @Getter @Setter(AccessLevel.PRIVATE) -@Builder(toBuilder = true) @NoArgsConstructor(access = AccessLevel.PRIVATE) @AllArgsConstructor(access = AccessLevel.PRIVATE) -public class GraphQLGeneratorOptions { +@Accessors(chain = true) +public class GraphQLGeneratorOptions extends AbstractGeneratorOptions { - QueryTypeOptions queryType; - MutationTypeOptions mutationType; - IdsOptions ids; + private InputOptions input ; + private QueryTypeOptions queryType; + private MutationTypeOptions mutationType; + private IdsOptions ids; /** * Load the options from an options file in YAML or Json. The options file may have missing @@ -65,75 +67,169 @@ public static GraphQLGeneratorOptions load(InputStream inputStream) throws IOExc ObjectMapper mapper = new ObjectMapper(new YAMLFactory()); - return mapper.readValue(inputStream, GraphQLGeneratorOptions.class); + GraphQLGeneratorOptions options = mapper.readValue(inputStream, GraphQLGeneratorOptions.class); + + options.validate() ; + + return options ; } - /** - * Creates a build class with the default options already loaded. This also for - * ease of overriding programmatically only a few options from their defaults. - * @return a build class with the default options already loaded. - */ - public static GraphQLGeneratorOptions.GraphQLGeneratorOptionsBuilder defaultBuilder() { - ObjectMapper objectMapper = new ObjectMapper(); - try { - GraphQLGeneratorOptions deepCopy = objectMapper - .readValue(objectMapper.writeValueAsString(load()), GraphQLGeneratorOptions.class); + public void validate() { + super.validate() ; - return deepCopy.toBuilder(); - } catch (JsonProcessingException e) { - throw new RuntimeException(e); - } + assert input != null : "Input Options are null"; + assert queryType != null : "Query Options are null"; + assert mutationType != null : "Mutation Options are null"; + assert ids != null : "Id Options are null"; + + input.validate() ; + queryType.validate() ; + mutationType.validate() ; + ids.validate() ; } /** - * Determines if the Generator should generate the Query Type. Short-cut for {@link QueryTypeOptions#generating} + * Determines if the Generator should generate the Query Type. * @return true if the Generator should generate the Query Type, false otherwise */ @JsonIgnore public boolean isGeneratingQueryType() { - return queryType != null && queryType.isGenerating(); + return isGeneratingSingleQueries() || isGeneratingListQueries() || isGeneratingSearchQueries() ; } /** * Determines if the Generator should generate any single query. Returns true if - * {@link SingleQueryOptions#generating} is set to true or - * {@link SingleQueryOptions#generatingFor} is set to true for any type + * {@link SingleQueryOptions#isGenerating} is set to true or * @return true if the Generator should generate any single query, false otherwise */ @JsonIgnore public boolean isGeneratingSingleQueries() { - return isGeneratingQueryType() && (queryType.getSingleQuery().isGenerating() || queryType.getSingleQuery().getGeneratingFor().values().stream().anyMatch(value -> value)); + return queryType.getSingleQuery().isGenerating() ; + } + + /** + * Determines if the Generator should generate the single query for a specific Primary Model. + * Returns true if {@link SingleQueryOptions#isGeneratingFor(String)} is set to true for the specified type + * @param name the name of the Primary Model + * @return true if the Generator should generate single query for a specific Primary Model, false otherwise + */ + @JsonIgnore + public boolean isGeneratingSingleQueryFor(String name) { + return queryType.getSingleQuery().isGeneratingFor(name) ; } /** - * Determines if the Generator should generate any list query. Returns true if - * {@link ListQueryOptions#generating} is set to true or - * {@link ListQueryOptions#generatingFor} is set to true for any type - * @return true if the Generator should generate any list query, false otherwise + * Determines if the Generator should generate any List Query. Returns true if + * {@link ListQueryOptions#isGenerating} is set to true for any type + * @return true if the Generator should generate any List Query, false otherwise */ @JsonIgnore public boolean isGeneratingListQueries() { - return isGeneratingQueryType() && (queryType.getListQuery().isGenerating() || queryType.getListQuery().getGeneratingFor().values().stream().anyMatch(value -> value)); + return queryType.getListQuery().isGenerating() ; } /** - * Determines if the Generator should generate any search query. Returns true if - * {@link SearchQueryOptions#generating} is set to true or - * {@link SearchQueryOptions#generatingFor} is set to true for any type - * @return true if the Generator should generate any search query, false otherwise + * Determines if the Generator should generate the List Query for a specific Primary Model. + * Returns true if {@link ListQueryOptions#isGeneratingFor(String)} is set to true for the specified type + * @param name the name of the Primary Model + * @return true if the Generator should generate List Query for a specific Primary Model, false otherwise + */ + @JsonIgnore + public boolean isGeneratingListQueryFor(String name) { + return queryType.getListQuery().isGeneratingFor(name) ; + } + + /** + * Determines if the Generator should generate any Search Query. Returns true if + * {@link SearchQueryOptions#isGenerating} is set to true + * @return true if the Generator should generate any Search Query, false otherwise */ @JsonIgnore public boolean isGeneratingSearchQueries() { - return isGeneratingQueryType() && (queryType.getSearchQuery().isGenerating() || queryType.getSearchQuery().getGeneratingFor().values().stream().anyMatch(value -> value)); + return queryType.getSearchQuery().isGenerating() ; + } + + /** + * Determines if the Generator should generate the Search Query for a specific Primary Model. + * Returns true if {@link SearchQueryOptions#isGeneratingFor(String)} is set to true for the specified type + * @param name the name of the Primary Model + * @return true if the Generator should generate Search Query for a specific Primary Model, false otherwise + */ + @JsonIgnore + public boolean isGeneratingSearchQueryFor(String name) { + return queryType.getSearchQuery().isGeneratingFor(name) ; } /** - * Determines if the Generator should generate the Mutation Type. Short-cut for {@link MutationTypeOptions#generating} + * Determines if the Generator should generate the Mutation Type. * @return true if the Generator should generate the Mutation Type, false otherwise */ @JsonIgnore public boolean isGeneratingMutationType() { - return mutationType != null && (mutationType.isGenerating() || mutationType.getGeneratingFor().values().stream().anyMatch(value -> value)); + return isGeneratingCreateMutation() || isGeneratingUpdateMutation() || isGeneratingDeleteMutation(); + } + + /** + * Determines if the Generator should generate the New mutations. Returns true if + * {@link CreateMutationOptions#isGenerating()} is set to true + * @return true if the Generator should generate New mutations, false otherwise + */ + @JsonIgnore + public boolean isGeneratingCreateMutation() { + return mutationType.getCreateMutation().isGenerating() ; + } + + /** + * Determines if the Generator should generate the New mutation for a specific Primary Model. + * Returns true if {@link CreateMutationOptions#isGeneratingFor(String)} is set to true for the specified type + * @param name the name of the Primary Model + * @return true if the Generator should generate Create mutation for a specific Primary Model, false otherwise + */ + @JsonIgnore + public boolean isGeneratingCreateMutationFor(String name) { + return mutationType.getCreateMutation().isGeneratingFor(name) ; + } + + /** + * Determines if the Generator should generate the Update mutations. Returns true if + * {@link UpdateMutationOptions#isGenerating()} is set to true + * @return true if the Generator should generate Update mutations, false otherwise + */ + @JsonIgnore + public boolean isGeneratingUpdateMutation() { + return mutationType.getUpdateMutation() != null && mutationType.getUpdateMutation().isGenerating() ; + } + + /** + * Determines if the Generator should generate the Update mutation for a specific Primary Model. + * Returns true if {@link UpdateMutationOptions#isGeneratingFor(String)} is set to true or the specified type + * @param name the name of the Primary Model + * @return true if the Generator should generate Update mutation for a specific Primary Model, false otherwise + */ + @JsonIgnore + public boolean isGeneratingUpdateMutationFor(String name) { + return mutationType.getUpdateMutation().isGeneratingFor(name) ; + } + + /** + * Determines if the Generator should generate the Delete mutations. Returns true if + * {@link DeleteMutationOptions#isGenerating} is set to true or + * @return true if the Generator should generate Delete mutations, false otherwise + */ + @JsonIgnore + public boolean isGeneratingDeleteMutation() { + return mutationType.getDeleteMutation() != null && mutationType.getDeleteMutation().isGenerating() ; + } + + /** + * Determines if the Generator should generate the Delete mutation for a specific Primary Model. + * Returns true if {@link DeleteMutationOptions#isGeneratingFor(String)} is set to true for the specified type + * @param name the name of the Primary Model + * @return true if the Generator should generate Delete mutation for a specific Primary Model, false otherwise + */ + @JsonIgnore + public boolean isGeneratingDeleteMutationFor(String name) { + return mutationType.getUpdateMutation().isGeneratingFor(name) ; } /** @@ -142,11 +238,87 @@ public boolean isGeneratingMutationType() { */ @JsonIgnore public boolean isUsingIDType() { - return ids != null && ids.isUsingIDType(); + return ids.isUsingIDType(); + } + + /** + * Gets the name of the List or Search Query input type for of specific primary model + * @param name the name of the primary model + * @return the name of the List or Search input type for of specific primary model + */ + @JsonIgnore + public final String getQueryInputTypeNameFor(@NonNull String name) { + return input.getTypeNameForQuery(queryType.getListQuery().getNameFor(name)) ; + } + + + /** + * Gets the name of the List or Search Query input type for of specific primary model + * @param type the primary model + * @return the name of the List or Search input type for of specific primary model + */ + @JsonIgnore + public final String getQueryInputTypeNameFor(@NonNull BrAPIType type) { + return getQueryInputTypeNameFor(type.getName()) ; + } + + /** + * Gets the name of the Single Query of specific primary model + * @param name the name of the primary model + * @return the name of the Single Query of specific primary model + */ + public String getSingleQueryNameFor(String name) { + return getNameFor(this.queryType.getSingleQuery(), name) ; + } + + /** + * Gets the name of the List Query of specific primary model + * @param name the name of the primary model + * @return the name of the List Query of specific primary model + */ + public String getListQueryNameFor(String name) { + return getNameFor(this.queryType.getListQuery(), name) ; + } + + /** + * Gets the name of the Search Query of specific primary model + * @param name the name of the primary model + * @return the name of the Search Query of specific primary model + */ + public String getSearchQueryNameFor(String name) { + return getNameFor(this.queryType.getSearchQuery(), name) ; + } + + /** + * Gets the name of the Create Mutation of specific primary model + * @param name the name of the primary model + * @return the name of the Create Mutation of specific primary model + */ + public String getCreateMutationNameFor(String name) { + return getNameFor(this.mutationType.getCreateMutation(), name) ; } /** - * + * Gets the name of the Update Mutation of specific primary model + * @param name the name of the primary model + * @return the name of the Update Mutation of specific primary model */ - public static class GraphQLGeneratorOptionsBuilder{} + public String getUpdateMutationNameFor(String name) { + return getNameFor(this.mutationType.getUpdateMutation(), name) ; + } + + /** + * Gets the name of the Delete Mutation of specific primary model + * @param name the name of the primary model + * @return the name of the Delete Mutation of specific primary model + */ + public String getDeleteMutationNameFor(String name) { + return getNameFor(this.mutationType.getDeleteMutation(), name) ; + } + + private String getNameFor(AbstractGraphQLOptions options, String name) { + String newName = options.isPluralisingName() ? getPluralFor(name) : name; + + return options.getNameFor(newName) ; + } } \ No newline at end of file diff --git a/java/core/src/main/java/org/brapi/schematools/core/graphql/options/IdsOptions.java b/java/core/src/main/java/org/brapi/schematools/core/graphql/options/IdsOptions.java index d14346e..8212dbc 100644 --- a/java/core/src/main/java/org/brapi/schematools/core/graphql/options/IdsOptions.java +++ b/java/core/src/main/java/org/brapi/schematools/core/graphql/options/IdsOptions.java @@ -1,18 +1,45 @@ package org.brapi.schematools.core.graphql.options; +import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.*; +import org.brapi.schematools.core.model.BrAPIType; +import org.brapi.schematools.core.utils.StringUtils; /** * Provides options for the generation of Ids */ @Getter -@Setter(AccessLevel.PRIVATE) -@Builder +@Setter @NoArgsConstructor(access = AccessLevel.PRIVATE) @AllArgsConstructor(access = AccessLevel.PRIVATE) public class IdsOptions { + @Getter(AccessLevel.PRIVATE) String nameFormat; @JsonProperty("useIDType") boolean usingIDType; + + public void validate() { + assert nameFormat != null : "'nameFormat' option on Mutation Ids Options is null"; + } + + /** + * Gets the name of the id for a specific primary model + * @param name the name of the primary model + * @return the name of the id for a specific primary model + */ + @JsonIgnore + public final String getNameFor(@NonNull String name) { + return String.format(nameFormat, StringUtils.toParameterCase(name)) ; + } + + /** + * Gets the name of id for a specific primary model + * @param type the primary model + * @return the name of the id for a specific primary model + */ + @JsonIgnore + public final String getNameFor(@NonNull BrAPIType type) { + return getNameFor(type.getName()); + } } diff --git a/java/core/src/main/java/org/brapi/schematools/core/graphql/options/InputOptions.java b/java/core/src/main/java/org/brapi/schematools/core/graphql/options/InputOptions.java new file mode 100644 index 0000000..869c248 --- /dev/null +++ b/java/core/src/main/java/org/brapi/schematools/core/graphql/options/InputOptions.java @@ -0,0 +1,73 @@ +package org.brapi.schematools.core.graphql.options; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.*; +import org.brapi.schematools.core.model.BrAPIType; +import org.brapi.schematools.core.utils.StringUtils; + +import static org.brapi.schematools.core.utils.StringUtils.toParameterCase; + +@Getter(AccessLevel.PRIVATE) +@Setter +@NoArgsConstructor(access = AccessLevel.PRIVATE) +@AllArgsConstructor(access = AccessLevel.PRIVATE) +public class InputOptions { + private String name; + private String nameFormat; + private String typeNameFormat; + + public void validate() { + assert name != null : "'name' option on Input Options is null"; + assert typeNameFormat != null : "'typeNameFormat' option on Input Options is null"; + } + + /** + * Gets the name of the input for a specific primary model + * @param name the name of the primary model + * @return the name of the input for a specific primary model + */ + @JsonIgnore + public final String getNameFor(@NonNull String name) { + return nameFormat != null ? String.format(nameFormat, toParameterCase(name)) : this.name ; + } + + /** + * Gets the name of input for a specific primary model + * @param type the primary model + * @return the name of the input for a specific primary model + */ + @JsonIgnore + public final String getNameFor(@NonNull BrAPIType type) { + return getNameFor(type.getName()); + } + + /** + * Gets the type name for a specific primary model + * @param name the name of the primary model + * @return the type name for a specific primary model + */ + @JsonIgnore + public final String getTypeNameFor(@NonNull String name) { + return String.format(typeNameFormat, name) ; + } + + /** + * Gets the type name for a specific primary model + * @param type the primary model + * @return the type name for a specific primary model + */ + @JsonIgnore + public final String getTypeNameFor(@NonNull BrAPIType type) { + return getTypeNameFor(type.getName()); + } + + /** + * Gets the type name for a query + * @param queryName the name of the query + * @return the name of the type name for a query + */ + @JsonIgnore + public final String getTypeNameForQuery(@NonNull String queryName) { + return String.format(typeNameFormat, StringUtils.toSentenceCase(queryName)) ; + } +} diff --git a/java/core/src/main/java/org/brapi/schematools/core/graphql/options/ListQueryOptions.java b/java/core/src/main/java/org/brapi/schematools/core/graphql/options/ListQueryOptions.java index 70d8f44..0e12023 100644 --- a/java/core/src/main/java/org/brapi/schematools/core/graphql/options/ListQueryOptions.java +++ b/java/core/src/main/java/org/brapi/schematools/core/graphql/options/ListQueryOptions.java @@ -1,8 +1,8 @@ package org.brapi.schematools.core.graphql.options; import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonProperty; import lombok.*; +import org.brapi.schematools.core.model.BrAPIType; import java.util.HashMap; import java.util.Map; @@ -11,42 +11,76 @@ * Provides options for the generation of List Queries */ @Getter -@Setter(AccessLevel.PRIVATE) -@Builder +@Setter @NoArgsConstructor(access = AccessLevel.PRIVATE) @AllArgsConstructor(access = AccessLevel.PRIVATE) -public class ListQueryOptions { - @JsonProperty("generate") - boolean generating; - String descriptionFormat; - String inputName; - String inputNameFormat; - String inputTypeNameFormat; - - String responseTypeNameFormat; - String dataFieldName; - - boolean pagedDefault; - @Builder.Default - Map paged = new HashMap<>(); - @Builder.Default - Map input = new HashMap<>(); - @JsonProperty("generateFor") - @Builder.Default - Map generatingFor = new HashMap<>(); - - String pagingInputName; - String pageInputTypeName; - String pageTypeName; - String pageFieldName; +public class ListQueryOptions extends AbstractGraphQLQueryOptions { + private String dataFieldName; + + @Getter(AccessLevel.PRIVATE) + private boolean pagedDefault; + @Getter(AccessLevel.NONE) + @Setter(AccessLevel.PRIVATE) + private Map paged = new HashMap<>(); + @Getter(AccessLevel.NONE) + @Setter(AccessLevel.PRIVATE) + private Map input = new HashMap<>(); + + private String pagingInputName; + private String pageInputTypeName; + private String pageTypeName; + private String pageFieldName; + + public void validate() { + super.validate(); + assert dataFieldName != null : String.format("'dataFieldName' option on %s is null", this.getClass().getSimpleName()); + assert paged != null : String.format("'paged' option on %s is null", this.getClass().getSimpleName()); + assert input != null : String.format("'input' option on %s is null", this.getClass().getSimpleName()); + assert pagingInputName != null : String.format("'pagingInputName' option on %s is null", this.getClass().getSimpleName()); + assert pageInputTypeName != null : String.format("'pageInputTypeName' option on %s is null", this.getClass().getSimpleName()); + assert pageTypeName != null : String.format("'pageTypeName' option on %s is null", this.getClass().getSimpleName()); + assert pageFieldName != null : String.format("'pageFieldName' option on %s is null", this.getClass().getSimpleName()); + } /** - * Determines if the List Query is generated for a specific primary model + * Determine if any list query has paging + * @return true if any list query has paging. false otherwise + */ + public boolean hasPaging() { + return pagedDefault || paged.values().stream().anyMatch(paged -> paged) ; + } + + + /** + * Determines if the Query is paged for a specific primary model * @param name the name of the primary model - * @return true if the List Query is generated for a specific primary model, false otherwise + * @return true if the Query is paged for a specific primary model, false otherwise */ @JsonIgnore - public boolean isGeneratingFor(String name) { - return generatingFor.getOrDefault(name, generating) ; + public final boolean isPagedFor(@NonNull String name) { + return paged.getOrDefault(name, pagedDefault) ; + } + + /** + * Determines if the Query is paged for a specific primary model + * @param type the primary model + * @return true if the Query is paged for a specific primary model, false otherwise + */ + @JsonIgnore + public final boolean isPagedFor(@NonNull BrAPIType type) { + return isPagedFor(type.getName()) ; + } + + /** + * Sets if the Query is paged for a specific primary model + * @param name the name of the primary model + * @param hasInput true if the Query is paged for a specific primary model, false otherwise + * @return the options for chaining + */ + @JsonIgnore + public final ListQueryOptions setPagedFor(String name, boolean hasInput) { + paged.put(name, hasInput) ; + + return this ; } } diff --git a/java/core/src/main/java/org/brapi/schematools/core/graphql/options/MutationTypeOptions.java b/java/core/src/main/java/org/brapi/schematools/core/graphql/options/MutationTypeOptions.java index 860a2d9..7e4340a 100644 --- a/java/core/src/main/java/org/brapi/schematools/core/graphql/options/MutationTypeOptions.java +++ b/java/core/src/main/java/org/brapi/schematools/core/graphql/options/MutationTypeOptions.java @@ -1,36 +1,36 @@ package org.brapi.schematools.core.graphql.options; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.*; - -import java.util.HashMap; -import java.util.Map; +import lombok.AccessLevel; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; /** * Provides options for the generation of the Mutation Type */ @Getter -@Setter(AccessLevel.PRIVATE) -@Builder +@Setter @NoArgsConstructor(access = AccessLevel.PRIVATE) @AllArgsConstructor(access = AccessLevel.PRIVATE) public class MutationTypeOptions { - @JsonProperty("generate") - boolean generating; - String name; - String descriptionFormat; - @JsonProperty("generateFor") - @Builder.Default - Map generatingFor = new HashMap<>(); + private String name; + @Setter(AccessLevel.PRIVATE) + private CreateMutationOptions createMutation; + @Setter(AccessLevel.PRIVATE) + private UpdateMutationOptions updateMutation; + @Setter(AccessLevel.PRIVATE) + private DeleteMutationOptions deleteMutation; + + public void validate() { + assert name != null : "Name option on Mutation Type Options is null"; + + assert createMutation != null : "Create Mutation Options are null"; + assert updateMutation != null : "Update Mutation Options are null"; + assert deleteMutation != null : "Delete Mutation Options are null"; - /** - * Determines if the Mutation is generated for a specific primary model - * @param name the name of the primary model - * @return true if the Mutation is generated for a specific primary model, false otherwise - */ - @JsonIgnore - public boolean isGeneratingFor(String name) { - return generatingFor.getOrDefault(name, generating) ; + createMutation.validate() ; + updateMutation.validate() ; + deleteMutation.validate() ; } } diff --git a/java/core/src/main/java/org/brapi/schematools/core/graphql/options/QueryTypeOptions.java b/java/core/src/main/java/org/brapi/schematools/core/graphql/options/QueryTypeOptions.java index b139e3f..b713cec 100644 --- a/java/core/src/main/java/org/brapi/schematools/core/graphql/options/QueryTypeOptions.java +++ b/java/core/src/main/java/org/brapi/schematools/core/graphql/options/QueryTypeOptions.java @@ -1,22 +1,37 @@ package org.brapi.schematools.core.graphql.options; -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.*; +import lombok.AccessLevel; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; /** * Provides options for the generation of the Query Type */ @Getter -@Setter(AccessLevel.PRIVATE) -@Builder +@Setter @NoArgsConstructor(access = AccessLevel.PRIVATE) @AllArgsConstructor(access = AccessLevel.PRIVATE) public class QueryTypeOptions { - @JsonProperty("generate") - boolean generating; - String name; - boolean partitionedByCrop; - SingleQueryOptions singleQuery; - ListQueryOptions listQuery; - SearchQueryOptions searchQuery; + private String name; + private boolean partitionedByCrop; + @Setter(AccessLevel.PRIVATE) + private SingleQueryOptions singleQuery ; + @Setter(AccessLevel.PRIVATE) + private ListQueryOptions listQuery; + @Setter(AccessLevel.PRIVATE) + private SearchQueryOptions searchQuery; + + public void validate() { + assert name != null : "Name option on QueryType Options is null"; + + assert singleQuery != null : "SingleQuery Options are null"; + assert listQuery != null : "ListQuery Options are null"; + assert searchQuery != null : "SearchQuery Options are null"; + + singleQuery.validate() ; + listQuery.validate() ; + searchQuery.validate() ; + } } diff --git a/java/core/src/main/java/org/brapi/schematools/core/graphql/options/SearchQueryOptions.java b/java/core/src/main/java/org/brapi/schematools/core/graphql/options/SearchQueryOptions.java index 8481ce9..3145742 100644 --- a/java/core/src/main/java/org/brapi/schematools/core/graphql/options/SearchQueryOptions.java +++ b/java/core/src/main/java/org/brapi/schematools/core/graphql/options/SearchQueryOptions.java @@ -1,36 +1,23 @@ package org.brapi.schematools.core.graphql.options; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.*; - -import java.util.HashMap; -import java.util.Map; +import lombok.AccessLevel; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; /** * Provides options for the generation of Search Queries */ @Getter -@Setter(AccessLevel.PRIVATE) -@Builder +@Setter @NoArgsConstructor(access = AccessLevel.PRIVATE) @AllArgsConstructor(access = AccessLevel.PRIVATE) -public class SearchQueryOptions { - @JsonProperty("generate") - boolean generating; - String nameFormat; - String descriptionFormat; - @JsonProperty("generateFor") - @Builder.Default - Map generatingFor = new HashMap<>(); +public class SearchQueryOptions extends AbstractGraphQLQueryOptions { + private String searchIdFieldName ; - /** - * Determines if the Search Query is generated for a specific primary model - * @param name the name of the primary model - * @return true if the Search Query is generated for a specific primary model, false otherwise - */ - @JsonIgnore - public boolean isGeneratingFor(String name) { - return generatingFor.getOrDefault(name, generating) ; + public void validate() { + super.validate(); + assert searchIdFieldName != null : String.format("'searchIdFieldName' option on %s is null", this.getClass().getSimpleName()); } } diff --git a/java/core/src/main/java/org/brapi/schematools/core/graphql/options/SingleQueryOptions.java b/java/core/src/main/java/org/brapi/schematools/core/graphql/options/SingleQueryOptions.java index ff28611..cde86be 100644 --- a/java/core/src/main/java/org/brapi/schematools/core/graphql/options/SingleQueryOptions.java +++ b/java/core/src/main/java/org/brapi/schematools/core/graphql/options/SingleQueryOptions.java @@ -1,35 +1,16 @@ package org.brapi.schematools.core.graphql.options; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.*; - -import java.util.HashMap; -import java.util.Map; +import lombok.AccessLevel; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.Setter; /** * Provides options for the generation of Single Queries */ @Getter -@Setter(AccessLevel.PRIVATE) -@Builder -@NoArgsConstructor(access = AccessLevel.PRIVATE) +@Setter @AllArgsConstructor(access = AccessLevel.PRIVATE) -public class SingleQueryOptions { - @JsonProperty("generate") - boolean generating; - String descriptionFormat; - @JsonProperty("generateFor") - @Builder.Default - Map generatingFor = new HashMap<>(); +public class SingleQueryOptions extends AbstractGraphQLOptions { - /** - * Determines if the Single Query is generated for a specific primary model - * @param name the name of the primary model - * @return true if the Single Query is generated for a specific primary model, false otherwise - */ - @JsonIgnore - public boolean isGeneratingFor(String name) { - return generatingFor.getOrDefault(name, generating) ; - } } diff --git a/java/core/src/main/java/org/brapi/schematools/core/graphql/options/UpdateMutationOptions.java b/java/core/src/main/java/org/brapi/schematools/core/graphql/options/UpdateMutationOptions.java new file mode 100644 index 0000000..e822394 --- /dev/null +++ b/java/core/src/main/java/org/brapi/schematools/core/graphql/options/UpdateMutationOptions.java @@ -0,0 +1,18 @@ +package org.brapi.schematools.core.graphql.options; + +import lombok.AccessLevel; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + +/** + * Provides options for the generation of Update Mutations + */ +@Getter +@Setter +@NoArgsConstructor(access = AccessLevel.PRIVATE) +@AllArgsConstructor(access = AccessLevel.PRIVATE) +public class UpdateMutationOptions extends AbstractGraphQLOptions { + boolean multiple; +} \ No newline at end of file diff --git a/java/core/src/main/java/org/brapi/schematools/core/openapi/OpenAPIGenerator.java b/java/core/src/main/java/org/brapi/schematools/core/openapi/OpenAPIGenerator.java index 1f163f9..1e9d4c3 100644 --- a/java/core/src/main/java/org/brapi/schematools/core/openapi/OpenAPIGenerator.java +++ b/java/core/src/main/java/org/brapi/schematools/core/openapi/OpenAPIGenerator.java @@ -1,6 +1,5 @@ package org.brapi.schematools.core.openapi; -import graphql.schema.GraphQLSchema; import io.swagger.v3.oas.models.Components; import io.swagger.v3.oas.models.OpenAPI; import io.swagger.v3.oas.models.Operation; @@ -15,7 +14,6 @@ import lombok.AllArgsConstructor; import org.brapi.schematools.core.brapischema.BrAPISchemaReader; import org.brapi.schematools.core.brapischema.BrAPISchemaReaderException; -import org.brapi.schematools.core.graphql.options.GraphQLGeneratorOptions; import org.brapi.schematools.core.model.*; import org.brapi.schematools.core.openapi.metadata.OpenAPIGeneratorMetadata; import org.brapi.schematools.core.openapi.options.OpenAPIGeneratorOptions; @@ -65,7 +63,7 @@ public OpenAPIGenerator(OpenAPIGeneratorOptions options) { * the BrAPI Json schema and the additional subdirectories called 'Requests' * that contains the request schemas and BrAPI-Common that contains common schemas * for use across modules. The list will contain a single {@link OpenAPI} or separate {@link OpenAPI} - * for each module. See {@link OpenAPIGeneratorOptions#separatingByModule}. + * for each module. See {@link OpenAPIGeneratorOptions#separateByModule}. * @param schemaDirectory the path to the complete BrAPI Specification * @param componentsDirectory the path to the additional OpenAPI components needed to generate the Specification * @return a list of {@link OpenAPI} generated from the complete BrAPI Specification @@ -156,69 +154,70 @@ private Response generate(String title, Collection types) { return Response.empty(). mergeOnCondition(options.isGeneratingEndpoint(), // these are GET and POST endpoints with the pattern / e.g. /locations () -> primaryTypes.stream(). - filter(type -> options.isGeneratingEndpointFor(type.getName())). + filter(options::isGeneratingEndpointFor). map(type -> generatePathItem(type).onSuccessDoWithResult( pathItem -> { - openAPI.path(createPathItemName(type.getName()), pathItem); + openAPI.path(createPathItemName(type), pathItem); })).collect(Response.toList())). mergeOnCondition(options.isGeneratingEndpointWithId(), // these are GET, PUT and DELETE endpoints with the pattern //{} e.g. /locations/{locationDbId} () -> primaryTypes.stream(). - filter(type -> options.isGeneratingEndpointNameWithIdFor(type.getName())). + filter(options::isGeneratingEndpointNameWithIdFor). map(type -> createPathItemWithId(type).onSuccessDoWithResult( pathItem -> { - openAPI.path(createPathItemWithIdName(type.getName()), pathItem); + openAPI.path(createPathItemWithIdName(type), pathItem); })).collect(Response.toList())). - mergeOnCondition(options.isGeneratingSearchEndpoint(), // this is a POST endpoint with the pattern /search/ e.g. /search/locations + mergeOnCondition(options.getSearch().isGenerating(), // this is a POST endpoint with the pattern /search/ e.g. /search/locations () -> primaryTypes.stream(). - filter(type -> options.isGeneratingSearchEndpointFor(type.getName())). + filter(type -> options.getSearch().isGeneratingFor(type)). map(type -> createSearchPathItem(type).onSuccessDoWithResult( pathItem -> { - openAPI.path(createSearchPathItemName(type.getName()), pathItem); + openAPI.path(createSearchPathItemName(type), pathItem); })).collect(Response.toList())). - mergeOnCondition(options.isGeneratingSearchEndpoint(), // this is a GET endpoint are endpoints with the pattern /search//{searchResultsDbId} e.g. /search/locations/{searchResultsDbId} + mergeOnCondition(options.getSearch().isGenerating(), // this is a GET endpoint are endpoints with the pattern /search//{searchResultsDbId} e.g. /search/locations/{searchResultsDbId} () -> primaryTypes.stream(). - filter(type -> options.isGeneratingSearchEndpointFor(type.getName())). + filter(type -> options.getSearch().isGeneratingFor(type)). map(type -> createSearchPathItemWithId(type).onSuccessDoWithResult( pathItem -> { - openAPI.path(createSearchPathItemWithIdName(type.getName()), pathItem); - })).collect(Response.toList())). + openAPI.path(createSearchPathItemWithIdName(type), pathItem); + })).collect(Response.toList()). merge(() -> generateComponents(primaryTypes, nonPrimaryTypes).onSuccessDoWithResult(openAPI::components)). - map(() -> success(openAPI)); + map(() -> success(openAPI))); } - private String createPathItemName(String entityName) { - return String.format("/%s", toParameterCase(options.getPluralFor(entityName))); + private String createPathItemName(BrAPIObjectType type) { + return options.getPathItemNameFor(type) ; } private Response generatePathItem(BrAPIObjectType type) { PathItem pathItem = new PathItem(); return Response.empty(). - mergeOnCondition(options.isGeneratingListGetEndpointFor(type.getName()), () -> generateListGetOperation(type).onSuccessDoWithResult(pathItem::setGet)). - mergeOnCondition(options.isGeneratingPostEndpointFor(type.getName()), () -> generatePostOperation(type).onSuccessDoWithResult(pathItem::setPost)). + mergeOnCondition(options.getListGet().isGeneratingFor(type), () -> generateListGetOperation(type).onSuccessDoWithResult(pathItem::setGet)). + mergeOnCondition(options.getPost().isGeneratingFor(type), () -> generatePostOperation(type).onSuccessDoWithResult(pathItem::setPost)). merge(() -> generateListResponse(type)). map(() -> success(pathItem)); } - private String createPathItemWithIdName(String entityName) { - return String.format("/%s/{%s}", toParameterCase(options.getPluralFor(entityName)), String.format(options.getIds().getNameFormat(), toParameterCase(entityName))); + private String createPathItemWithIdName(BrAPIObjectType type) { + return options.getPathItemWithIdNameFor(type) ; + } public Response createPathItemWithId(BrAPIObjectType type) { PathItem pathItem = new PathItem(); return Response.empty(). - mergeOnCondition(options.isGeneratingSingleGetEndpointFor(type.getName()), () -> generateSingleGetOperation(type).onSuccessDoWithResult(pathItem::setGet)). - mergeOnCondition(options.isGeneratingPutEndpointFor(type.getName()), () -> generatePutOperation(type).onSuccessDoWithResult(pathItem::setPut)). - mergeOnCondition(options.isGeneratingDeleteEndpointFor(type.getName()), () -> generateDeleteOperation(type).onSuccessDoWithResult(pathItem::setDelete)). + mergeOnCondition(options.getSingleGet().isGeneratingFor(type), () -> generateSingleGetOperation(type).onSuccessDoWithResult(pathItem::setGet)). + mergeOnCondition(options.getPut().isGeneratingFor(type), () -> generatePutOperation(type).onSuccessDoWithResult(pathItem::setPut)). + mergeOnCondition(options.getDelete().isGeneratingFor(type), () -> generateDeleteOperation(type).onSuccessDoWithResult(pathItem::setDelete)). merge(() -> generateSingleResponse(type)). map(() -> success(pathItem)); } private Response generateSingleResponse(BrAPIObjectType type) { - String name = options.getListResponseNameFor(type.getName()); + String name = options.getListResponseNameFor(type); ApiResponse apiResponse = new ApiResponse().description("OK").content( new Content().addMediaType("application/json", @@ -239,7 +238,7 @@ private Response generateSingleResponse(BrAPIObjectType type) { } private Response generateListResponse(BrAPIObjectType type) { - String name = options.getSingleResponseNameFor(type.getName()); + String name = options.getSingleResponseNameFor(type); ApiResponse apiResponse = new ApiResponse().description("OK").content( new Content().addMediaType("application/json", @@ -265,11 +264,11 @@ private Response generateListResponse(BrAPIObjectType type) { private Response generateListGetOperation(BrAPIObjectType type) { Operation operation = new Operation(); - operation.setSummary(metadata.getListGet().getSummaries().getOrDefault(type.getName(), String.format(options.getListGet().getSummaryFormat(), options.getPluralFor(type.getName())))) ; - operation.setDescription(metadata.getListGet().getDescriptions().getOrDefault(type.getName(), String.format(options.getListGet().getDescriptionFormat(), options.getPluralFor(type.getName())))); + operation.setSummary(metadata.getListGet().getSummaries().getOrDefault(type.getName(), options.getListGet().getSummaryFor(type))) ; + operation.setDescription(metadata.getListGet().getDescriptions().getOrDefault(type.getName(), options.getListGet().getDescriptionFor(type))) ; operation.responses(createListApiResponses(type)) ; - operation.addTagsItem(options.getPluralFor(type.getName())) ; + operation.addTagsItem(options.getPluralFor(type)) ; return createListGetParametersFor(type). onSuccessDoWithResult(operation::parameters). @@ -277,28 +276,38 @@ private Response generateListGetOperation(BrAPIObjectType type) { } private Response> createListGetParametersFor(BrAPIObjectType type) { - BrAPIClass requestSchema = this.brAPISchemas.get(String.format("%sRequest", type.getName())); - if (requestSchema == null) { - return fail(Response.ErrorType.VALIDATION, String.format("Can not find '%sRequest' to create parameters for list get endpoint for '%s'", type.getName(), createSearchPathItemName(type.getName()))) ; - } - - if (requestSchema instanceof BrAPIObjectType brAPIObjectType) { - List parameters = new ArrayList<>(); + List parameters = new ArrayList<>(); + if (type.getProperties().stream().anyMatch(property -> property.getName().equals("externalReferences"))) { parameters.add(new Parameter().$ref("#/components/parameters/externalReferenceID")); parameters.add(new Parameter().$ref("#/components/parameters/externalReferenceId")); // TODO depreciated, remove? parameters.add(new Parameter().$ref("#/components/parameters/externalReferenceSource")); + } + + if (options.getListGet().isPagedFor(type)) { parameters.add(new Parameter().$ref("#/components/parameters/page")); parameters.add(new Parameter().$ref("#/components/parameters/pageSize")); parameters.add(new Parameter().$ref("#/components/parameters/authorizationHeader")); + } - return brAPIObjectType.getProperties().stream().map(this::createListGetParameter).collect(Response.toList()). - onSuccessDoWithResult(result -> parameters.addAll(0, result)). - map(() -> success(parameters)); - } else { - return fail(Response.ErrorType.VALIDATION, String.format("'%sRequest' must be BrAPIObjectType but was '%s'", type.getName(), type.getClass().getSimpleName())) ; + if (options.getListGet().hasInputFor(type)) { + BrAPIClass requestSchema = this.brAPISchemas.get(String.format("%sRequest", type.getName())); + + if (requestSchema == null) { + return fail(Response.ErrorType.VALIDATION, String.format("Can not find '%sRequest' to create parameters for list get endpoint for '%s'", type.getName(), createPathItemName(type))) ; + } + + if (requestSchema instanceof BrAPIObjectType brAPIObjectType) { + return brAPIObjectType.getProperties().stream().map(this::createListGetParameter).collect(Response.toList()). + onSuccessDoWithResult(result -> parameters.addAll(0, result)). + map(() -> success(parameters)); + } else { + return fail(Response.ErrorType.VALIDATION, String.format("'%sRequest' must be BrAPIObjectType but was '%s'", type.getName(), type.getClass().getSimpleName())) ; + } } + + return success(parameters) ; } private Response createListGetParameter(BrAPIObjectProperty property) { @@ -322,13 +331,12 @@ private Schema upwrapSchema(Schema schema) { private Response generatePostOperation(BrAPIObjectType type) { Operation operation = new Operation(); - operation.setSummary(metadata.getPost().getSummaries().getOrDefault(type.getName(), String.format(options.getPost().getSummaryFormat(), type.getName()))) ; - operation.setDescription(metadata.getPost().getDescriptions().getOrDefault(type.getName(), String.format(options.getPost().getDescriptionFormat(), type.getName()))); + operation.setSummary(metadata.getPost().getSummaries().getOrDefault(type.getName(), options.getPost().getSummaryFor(type))) ; + operation.setDescription(metadata.getPost().getDescriptions().getOrDefault(type.getName(), options.getPost().getDescriptionFor(type))) ; operation.addParametersItem(new Parameter().$ref("#/components/parameters/authorizationHeader")) ; - String requestBodyName = options.getCreatingNewRequestFor().getOrDefault(type.getName(), options.isCreatingNewRequest()) ? - String.format(options.getNewRequestNameFormat(), type.getName()) : type.getName() ; + String requestBodyName = options.isGeneratingNewRequestFor(type) ? options.getNewRequestNameFor(type) : type.getName() ; operation.requestBody( new RequestBody().content( @@ -337,7 +345,7 @@ private Response generatePostOperation(BrAPIObjectType type) { new ArraySchema().$ref(String.format("#/components/schemas/%s", requestBodyName)))))); operation.responses(createListApiResponses(type)) ; - operation.addTagsItem(options.getPluralFor(type.getName())) ; + operation.addTagsItem(options.getPluralFor(type)) ; return success(operation); } @@ -345,11 +353,11 @@ private Response generatePostOperation(BrAPIObjectType type) { private Response generateSingleGetOperation(BrAPIObjectType type) { Operation operation = new Operation(); - operation.setSummary(metadata.getSingleGet().getSummaries().getOrDefault(type.getName(), String.format(options.getSingleGet().getSummaryFormat(), type.getName()))) ; - operation.setDescription(metadata.getSingleGet().getDescriptions().getOrDefault(type.getName(), String.format(options.getSingleGet().getDescriptionFormat(), type.getName()))); + operation.setSummary(metadata.getPost().getSummaries().getOrDefault(type.getName(), options.getSingleGet().getSummaryFor(type))) ; + operation.setDescription(metadata.getPost().getDescriptions().getOrDefault(type.getName(), options.getSingleGet().getDescriptionFor(type))) ; operation.responses(createSingleApiResponses(type)) ; - operation.addTagsItem(options.getPluralFor(type.getName())) ; + operation.addTagsItem(options.getPluralFor(type)) ; return success(operation); } @@ -357,11 +365,11 @@ private Response generateSingleGetOperation(BrAPIObjectType type) { private Response generatePutOperation(BrAPIObjectType type) { Operation operation = new Operation(); - operation.setSummary(metadata.getPut().getSummaries().getOrDefault(type.getName(), String.format(options.getPut().getSummaryFormat(), type.getName()))) ; - operation.setDescription(metadata.getPut().getDescriptions().getOrDefault(type.getName(), String.format(options.getPut().getDescriptionFormat(), type.getName()))); + operation.setSummary(metadata.getPost().getSummaries().getOrDefault(type.getName(), options.getPut().getSummaryFor(type))) ; + operation.setDescription(metadata.getPost().getDescriptions().getOrDefault(type.getName(), options.getPut().getDescriptionFor(type))) ; operation.responses(createSingleApiResponses(type)) ; - operation.addTagsItem(options.getPluralFor(type.getName())) ; + operation.addTagsItem(options.getPluralFor(type)) ; return success(operation); } @@ -369,11 +377,11 @@ private Response generatePutOperation(BrAPIObjectType type) { private Response generateDeleteOperation(BrAPIObjectType type) { Operation operation = new Operation(); - operation.setSummary(metadata.getDelete().getSummaries().getOrDefault(type.getName(), String.format(options.getDelete().getSummaryFormat(), type.getName()))) ; - operation.setDescription(metadata.getDelete().getDescriptions().getOrDefault(type.getName(), String.format(options.getDelete().getDescriptionFormat(), type.getName()))); + operation.setSummary(metadata.getPost().getSummaries().getOrDefault(type.getName(), options.getDelete().getSummaryFor(type))) ; + operation.setDescription(metadata.getPost().getDescriptions().getOrDefault(type.getName(), options.getDelete().getDescriptionFor(type))) ; operation.responses(createSingleApiResponses(type)) ; - operation.addTagsItem(options.getPluralFor(type.getName())) ; + operation.addTagsItem(options.getPluralFor(type)) ; return success(operation); } @@ -395,12 +403,12 @@ private ApiResponses addStandardApiResponses(ApiResponses apiResponses) { addApiResponse("403", new ApiResponse().$ref("#/components/responses/403Forbidden")) ; } - private String createSearchPathItemName(String entityName) { - return String.format("/search/%s", toParameterCase(options.getPluralFor(entityName))); + private String createSearchPathItemName(BrAPIObjectType type) { + return String.format("/search/%s", toParameterCase(options.getPluralFor(type))); } - private String createSearchPathItemWithIdName(String entityName) { - return String.format("/search/%s/{%s}", toParameterCase(options.getPluralFor(entityName)), String.format(options.getIds().getNameFormat(), toParameterCase(entityName))); + private String createSearchPathItemWithIdName(BrAPIObjectType type) { + return String.format("/search/%s/{%s}", toParameterCase(options.getPluralFor(type)), options.getIds().getIDParameterFor(type)); } public Response createSearchPathItem(BrAPIObjectType type) { @@ -408,11 +416,11 @@ public Response createSearchPathItem(BrAPIObjectType type) { Operation operation = new Operation(); - operation.setSummary(metadata.getSearch().getSummaries().getOrDefault(type.getName(), String.format(options.getSearch().getSummaryFormat(), type.getName()))) ; - operation.setDescription(metadata.getSearch().getDescriptions().getOrDefault(type.getName(), String.format(options.getSearch().getSubmitDescriptionFormat(), type.getName(), toParameterCase(type.getName())))); + operation.setSummary(metadata.getSearch().getSummaries().getOrDefault(type.getName(), options.getSearch().getSummaryFor(type))) ; + operation.setDescription(metadata.getSearch().getDescriptions().getOrDefault(type.getName(), options.getSearch().getSubmitDescriptionFormat(type))); operation.responses(createSearchPostResponseRefs(type)) ; - operation.addTagsItem(options.getPluralFor(type.getName())) ; + operation.addTagsItem(options.getPluralFor(type)) ; pathItem.setPost(operation); @@ -430,11 +438,11 @@ public Response createSearchPathItemWithId(BrAPIObjectType type) { Operation operation = new Operation(); - operation.setSummary(metadata.getSearch().getSummaries().getOrDefault(type.getName(), String.format(options.getSearch().getSummaryFormat(), type.getName()))) ; - operation.setDescription(metadata.getSearch().getDescriptions().getOrDefault(type.getName(), String.format(options.getSearch().getRetrieveDescriptionFormat(), type.getName(), toParameterCase(type.getName())))); + operation.setSummary(metadata.getSearch().getSummaries().getOrDefault(type.getName(), options.getSearch().getSubmitDescriptionFormat(type))); + operation.setDescription(metadata.getSearch().getDescriptions().getOrDefault(type.getName(), options.getSearch().getRetrieveDescriptionFormat(type))); operation.responses(createSearchGetResponseRefs(type)) ; - operation.addTagsItem(options.getPluralFor(type.getName())) ; + operation.addTagsItem(options.getPluralFor(type)) ; pathItem.setGet(operation); @@ -473,21 +481,21 @@ private Response> generateSchemasForType(BrAPIObjectType typ Map schemas = new HashMap<>() ; - boolean creatingNewRequest = options.isGeneratingNewRequestFor(type.getName()) ; + boolean creatingNewRequest = options.isGeneratingNewRequestFor(type) ; return Response.empty(). merge( () -> createSchemaForType(type, creatingNewRequest).onSuccessDoWithResult(result -> schemas.put(type.getName(), result))). mergeOnCondition(creatingNewRequest, - () -> createNewRequestSchemaForType(type).onSuccessDoWithResult(result -> schemas.put(options.getNewRequestNameFor(type.getName()), result))). - mergeOnCondition(options.isGeneratingSearchRequestFor(type.getName()), - () -> createSearchRequestSchemaForType(type).onSuccessDoWithResult(result -> schemas.put(options.getSearchRequestNameFor(type.getName()), result))). + () -> createNewRequestSchemaForType(type).onSuccessDoWithResult(result -> schemas.put(options.getNewRequestNameFor(type), result))). + mergeOnCondition(options.getSearch().isGeneratingFor(type), + () -> createSearchRequestSchemaForType(type).onSuccessDoWithResult(result -> schemas.put(options.getSearchRequestNameFor(type), result))). map(() -> success(schemas)) ; } private Response createSchemaForType(BrAPIObjectType type, boolean creatingNewRequest) { if (creatingNewRequest) { - String idParameter = options.getIds().getIDParameterFor(type.getName()) ; + String idParameter = options.getIds().getIDParameterFor(type) ; return type.getProperties().stream().filter(property -> property.getName().equals(idParameter)).findAny().map(this::createProperty). orElse(fail(Response.ErrorType.VALIDATION, String.format("Can not find property '%s' in type '%s'", idParameter, type.getName()))). @@ -501,7 +509,7 @@ private Response createSchemaForType(BrAPIObjectType type, boolean creat } private Response createNewRequestSchemaForType(BrAPIObjectType type) { - String idParameter = options.getIds().getIDParameterFor(type.getName()) ; + String idParameter = options.getIds().getIDParameterFor(type) ; return createProperties(type.getProperties().stream().filter(property -> !property.getName().equals(idParameter)).toList()).mapResult( schema -> new ObjectSchema().properties(schema).name(type.getName()).description(type.getDescription())) ; @@ -510,7 +518,7 @@ private Response createNewRequestSchemaForType(BrAPIObjectType type) { private Response createSearchRequestSchemaForType(BrAPIObjectType type) { BrAPIClass requestSchema = this.brAPISchemas.get(String.format("%sRequest", type.getName())); - String name = options.getSearchRequestNameFor(type.getName()) ; + String name = options.getSearchRequestNameFor(type) ; if (requestSchema == null) { return fail(Response.ErrorType.VALIDATION, String.format("Can not find '%sRequest' when creating '%s'", type.getName(), name)) ; diff --git a/java/core/src/main/java/org/brapi/schematools/core/openapi/options/AbstractOpenAPIOptions.java b/java/core/src/main/java/org/brapi/schematools/core/openapi/options/AbstractOpenAPIOptions.java new file mode 100644 index 0000000..57413cb --- /dev/null +++ b/java/core/src/main/java/org/brapi/schematools/core/openapi/options/AbstractOpenAPIOptions.java @@ -0,0 +1,44 @@ +package org.brapi.schematools.core.openapi.options; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.*; +import org.brapi.schematools.core.model.BrAPIType; +import org.brapi.schematools.core.options.AbstractOptions; + + +/** + * Provides general options for the generation of Endpoints + */ +@Getter(AccessLevel.PRIVATE) +@Setter +@NoArgsConstructor(access = AccessLevel.PROTECTED) +@AllArgsConstructor(access = AccessLevel.PROTECTED) +public abstract class AbstractOpenAPIOptions extends AbstractOptions { + private String summaryFormat; + + public void validate() { + super.validate(); + assert summaryFormat != null : String.format("'summaryFormat' option on %s is null", this.getClass().getSimpleName()); + } + + /** + * Gets the summary for a specific primary model + * @param name the name of the primary model + * @return the summary for a specific primary model + */ + @JsonIgnore + private final String getSummaryFor(@NonNull String name) { + return String.format(summaryFormat, name) ; + } + + /** + * Gets the summary for a specific primary model + * @param type the primary model + * @return the summary for a specific primary model + */ + @JsonIgnore + public final String getSummaryFor(@NonNull BrAPIType type) { + return getSummaryFor(type.getName()); + } +} + diff --git a/java/core/src/main/java/org/brapi/schematools/core/openapi/options/DeleteOptions.java b/java/core/src/main/java/org/brapi/schematools/core/openapi/options/DeleteOptions.java index 2ff5a56..d7f7288 100644 --- a/java/core/src/main/java/org/brapi/schematools/core/openapi/options/DeleteOptions.java +++ b/java/core/src/main/java/org/brapi/schematools/core/openapi/options/DeleteOptions.java @@ -1,36 +1,8 @@ package org.brapi.schematools.core.openapi.options; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.*; - -import java.util.HashMap; -import java.util.Map; - /** * Provides options for the generation of Delete Endpoints */ -@Getter -@Setter(AccessLevel.PRIVATE) -@Builder -@NoArgsConstructor(access = AccessLevel.PRIVATE) -@AllArgsConstructor(access = AccessLevel.PRIVATE) -public class DeleteOptions { - @JsonProperty("generate") - boolean generating; - String summaryFormat; - String descriptionFormat; - @JsonProperty("generateFor") - @Builder.Default - Map generatingFor = new HashMap<>(); +public class DeleteOptions extends AbstractOpenAPIOptions { - /** - * Determines if the Delete Endpoint is generated for a specific primary model - * @param name the name of the primary model - * @return true if the Delete Endpoint is generated for a specific primary model, false otherwise - */ - @JsonIgnore - public boolean isGeneratingFor(String name) { - return generatingFor.getOrDefault(name, generating) ; - } } diff --git a/java/core/src/main/java/org/brapi/schematools/core/openapi/options/IdsOptions.java b/java/core/src/main/java/org/brapi/schematools/core/openapi/options/IdsOptions.java index e98904a..ca8a6e0 100644 --- a/java/core/src/main/java/org/brapi/schematools/core/openapi/options/IdsOptions.java +++ b/java/core/src/main/java/org/brapi/schematools/core/openapi/options/IdsOptions.java @@ -1,8 +1,12 @@ package org.brapi.schematools.core.openapi.options; import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.*; +import lombok.AccessLevel; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import org.brapi.schematools.core.model.BrAPIType; import java.util.HashMap; import java.util.Map; @@ -12,21 +16,23 @@ /** * Provides options for the generation of Ids */ -@Getter -@Setter(AccessLevel.PRIVATE) -@Builder +@Getter(AccessLevel.PRIVATE) +@Setter @NoArgsConstructor(access = AccessLevel.PRIVATE) @AllArgsConstructor(access = AccessLevel.PRIVATE) public class IdsOptions { - String nameFormat; + private String nameFormat; + @Setter(AccessLevel.PRIVATE) + private Map parameterFor = new HashMap<>(); - @JsonProperty("generateFor") - @Builder.Default - Map parameterFor = new HashMap<>(); + public void validate() { + assert nameFormat != null : String.format("'nameFormat' option on %s is null", this.getClass().getSimpleName()); + assert parameterFor != null : String.format("'parameterFor' option on %s is null", this.getClass().getSimpleName()); + } /** * Gets the id parameter name for a specific primary model. For example the id parameter (or field) - * name of Study, would be 'studyDbiId' by default. Use {@link #parameterFor} to override this value. + * name of Study, would be 'studyDbiId' by default. Use {@link #setIDParameterFor} to override this value. * @param name the name of the primary model * @return id parameter name for a specific primary model */ @@ -34,4 +40,40 @@ public class IdsOptions { public String getIDParameterFor(String name) { return parameterFor.getOrDefault(name, String.format(nameFormat, toParameterCase(name))) ; } + + /** + * Gets the id parameter name for a specific primary model. For example the id parameter (or field) + * name of Study, would be 'studyDbiId' by default. Use {@link #setIDParameterFor} to override this value. + * @param type the primary model + * @return id parameter name for a specific primary model + */ + public String getIDParameterFor(BrAPIType type) { + return getIDParameterFor(type.getName()) ; + } + + /** + * Sets the id parameter name for a specific primary model. For example the id parameter (or field) + * name of Study, would be 'studyDbiId' by default. + * @param name the name of the primary model + * @param idParameter the id parameter name for a specific primary model. + * @return the options for chaining + */ + @JsonIgnore + public IdsOptions setIDParameterFor(String name, String idParameter) { + parameterFor.put(name, idParameter) ; + + return this ; + } + + /** + * Sets the id parameter name for a specific primary model. For example the id parameter (or field) + * name of Study, would be 'studyDbiId' by default. + * @param type the primary model + * @param idParameter the id parameter name for a specific primary model. + * @return the options for chaining + */ + @JsonIgnore + public IdsOptions setIDParameterFor(BrAPIType type, String idParameter) { + return setIDParameterFor(type.getName(), idParameter) ; + } } diff --git a/java/core/src/main/java/org/brapi/schematools/core/openapi/options/ListGetOptions.java b/java/core/src/main/java/org/brapi/schematools/core/openapi/options/ListGetOptions.java index 84c8dd8..f22d3ae 100644 --- a/java/core/src/main/java/org/brapi/schematools/core/openapi/options/ListGetOptions.java +++ b/java/core/src/main/java/org/brapi/schematools/core/openapi/options/ListGetOptions.java @@ -1,8 +1,11 @@ package org.brapi.schematools.core.openapi.options; import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.*; +import lombok.AccessLevel; +import lombok.Getter; +import lombok.Setter; +import org.brapi.schematools.core.model.BrAPIType; +import org.brapi.schematools.core.options.AbstractOptions; import java.util.HashMap; import java.util.Map; @@ -10,27 +13,104 @@ /** * Provides options for the generation of List Get Endpoints */ -@Getter -@Setter(AccessLevel.PRIVATE) -@Builder -@NoArgsConstructor(access = AccessLevel.PRIVATE) -@AllArgsConstructor(access = AccessLevel.PRIVATE) -public class ListGetOptions { - @JsonProperty("generate") - boolean generating; - String summaryFormat; - String descriptionFormat; - @JsonProperty("generateFor") - @Builder.Default - Map generatingFor = new HashMap<>(); - - /** - * Determines if the List Get Endpoint is generated for a specific primary model +@Getter(AccessLevel.PRIVATE) +@Setter +public class ListGetOptions extends AbstractOpenAPIOptions { + private boolean pagedDefault; + @Setter(AccessLevel.PRIVATE) + private Map paged = new HashMap<>(); + @Setter(AccessLevel.PRIVATE) + private Map inputFor = new HashMap<>(); + + public void validate() { + super.validate(); + assert paged != null : String.format("'paged' option on %s is null", this.getClass().getSimpleName()); + assert inputFor != null : String.format("'inputFor' option on %s is null", this.getClass().getSimpleName()); + } + + /** + * Determines if the List Endpoint is paged for any primary model. Returns true if + * {@link ListGetOptions#paged} is set to true for any type or uses {@link ListGetOptions#pagedDefault} + * @param name the name of the primary model + * @return true if the List Endpoint is paged for any primary model, false otherwise + */ + @JsonIgnore + public boolean isPagedFor(String name) { + return paged.getOrDefault(name, pagedDefault) ; + } + + /** + * Determines if the List Endpoint is paged for any primary model. Returns true if + * {@link ListGetOptions#paged} is set to true for any type or uses {@link ListGetOptions#pagedDefault} + * @param type the primary model + * @return true if the List Endpoint is paged for any primary model, false otherwise + */ + public boolean isPagedFor(BrAPIType type) { + return isPagedFor(type.getName()) ; + } + + /** + * Sets if the Endpoint is paged for a specific primary model. + * @param generate true if the Endpoint is paged for a specific primary model, false + * @return the options for chaining + */ + @JsonIgnore + public AbstractOptions setPagingFor(String name, boolean generate) { + paged.put(name, generate) ; + + return this ; + } + + /** + * Sets if the Endpoint is paged for a specific primary model. + * @param generate true if the Endpoint is paged for a specific primary model, false + * @return the options for chaining + */ + @JsonIgnore + public AbstractOptions setPagingFor(BrAPIType type, boolean generate) { + return setPagingFor(type.getName(), generate) ; + } + + /** + * Determines if the List Endpoint is has an input for any primary model. Returns true if + * {@link ListGetOptions#inputFor} is set to true for the primary model * @param name the name of the primary model - * @return true if the List Get Endpoint is generated for a specific primary model, false otherwise + * @return true if the List Endpoint has an input for the primary model, false otherwise + */ + @JsonIgnore + public boolean hasInputFor(String name) { + return inputFor.getOrDefault(name, pagedDefault) ; + } + + /** + * Determines if the List Endpoint has an input for any primary model. Returns true if + * * {@link ListGetOptions#inputFor} is set to true for the primary model + * @param type the primary model + * @return true if the List Endpoint has an input for the primary model, false otherwise + */ + public boolean hasInputFor(BrAPIType type) { + return hasInputFor(type.getName()) ; + } + + /** + * Sets if the Endpoint has an input for a specific primary model. + * @param generate true if the Endpoint has an input for a specific primary model, false + * @return the options for chaining + */ + @JsonIgnore + public AbstractOptions setInputFor(String name, boolean generate) { + inputFor.put(name, generate) ; + + return this ; + } + + /** + * Sets if the Endpoint has an input for a specific primary model. + * @param generate true if the Endpoint has an input for a specific primary model, false + * @return the options for chaining */ @JsonIgnore - public boolean isGeneratingFor(String name) { - return generatingFor.getOrDefault(name, generating) ; + public AbstractOptions setInputFor(BrAPIType type, boolean generate) { + return setInputFor(type.getName(), generate) ; } } diff --git a/java/core/src/main/java/org/brapi/schematools/core/openapi/options/OpenAPIGeneratorOptions.java b/java/core/src/main/java/org/brapi/schematools/core/openapi/options/OpenAPIGeneratorOptions.java index c7711e2..0c0c4b9 100644 --- a/java/core/src/main/java/org/brapi/schematools/core/openapi/options/OpenAPIGeneratorOptions.java +++ b/java/core/src/main/java/org/brapi/schematools/core/openapi/options/OpenAPIGeneratorOptions.java @@ -1,14 +1,13 @@ package org.brapi.schematools.core.openapi.options; import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; import lombok.*; -import org.brapi.schematools.core.graphql.options.QueryTypeOptions; -import org.brapi.schematools.core.graphql.options.SingleQueryOptions; +import lombok.experimental.Accessors; +import org.brapi.schematools.core.model.BrAPIType; import org.brapi.schematools.core.openapi.OpenAPIGenerator; +import org.brapi.schematools.core.options.AbstractGeneratorOptions; import java.io.IOException; import java.io.InputStream; @@ -17,7 +16,7 @@ import java.util.HashMap; import java.util.Map; -import static org.brapi.schematools.core.utils.StringUtils.toPlural; +import static org.brapi.schematools.core.utils.StringUtils.toParameterCase; import static org.brapi.schematools.core.utils.StringUtils.toSingular; @@ -25,30 +24,45 @@ * Options for the {@link OpenAPIGenerator}. */ @Getter -@Setter(AccessLevel.PRIVATE) -@Builder(toBuilder = true) +@Setter @NoArgsConstructor(access = AccessLevel.PRIVATE) @AllArgsConstructor(access = AccessLevel.PRIVATE) -public class OpenAPIGeneratorOptions { - - @JsonProperty("separateByModule") - boolean separatingByModule; - SingleGetOptions singleGet; - ListGetOptions listGet; - PostOptions post; - PutOptions put; - DeleteOptions delete; - SearchOptions search; - IdsOptions ids; - @JsonProperty("createNewRequest") - boolean creatingNewRequest; - @JsonProperty("createNewRequestFor") - @Builder.Default - Map creatingNewRequestFor = new HashMap<>(); - String newRequestNameFormat; - String singleResponseNameFormat; - String listResponseNameFormat; - String searchRequestNameFormat; +@Accessors(chain = true) +public class OpenAPIGeneratorOptions extends AbstractGeneratorOptions { + + @Setter(AccessLevel.PRIVATE) + private SingleGetOptions singleGet; + @Setter(AccessLevel.PRIVATE) + private ListGetOptions listGet; + @Setter(AccessLevel.PRIVATE) + private PostOptions post; + @Setter(AccessLevel.PRIVATE) + private PutOptions put; + @Setter(AccessLevel.PRIVATE) + private DeleteOptions delete; + @Setter(AccessLevel.PRIVATE) + private SearchOptions search; + @Setter(AccessLevel.PRIVATE) + private IdsOptions ids; + + @Getter(AccessLevel.PRIVATE) + boolean separateByModule; + @Getter(AccessLevel.PRIVATE) + private boolean generateNewRequest; + @Getter(AccessLevel.NONE) + @Setter(AccessLevel.PRIVATE) + private Map generateNewRequestFor = new HashMap<>(); + @Getter(AccessLevel.PRIVATE) + private String newRequestNameFormat; + @Getter(AccessLevel.PRIVATE) + private String singleResponseNameFormat; + @Getter(AccessLevel.PRIVATE) + private String listResponseNameFormat; + @Getter(AccessLevel.PRIVATE) + private String searchRequestNameFormat; + @Getter(AccessLevel.NONE) + @Setter(AccessLevel.PRIVATE) + private Map pathItemNameFor = new HashMap<>(); /** * Load the options from an options file in YAML or Json. The options file may have missing @@ -88,223 +102,138 @@ public static OpenAPIGeneratorOptions load(InputStream inputStream) throws IOExc ObjectMapper mapper = new ObjectMapper(new YAMLFactory()); - return mapper.readValue(inputStream, OpenAPIGeneratorOptions.class); - } - - /** - * Creates a build class with the default options already loaded. This also for - * ease of overriding programmatically only a few options from their defaults. - * @return a build class with the default options already loaded. - */ - public static OpenAPIGeneratorOptions.OpenAPIGeneratorOptionsBuilder defaultBuilder() { - ObjectMapper objectMapper = new ObjectMapper(); - try { - OpenAPIGeneratorOptions deepCopy = objectMapper - .readValue(objectMapper.writeValueAsString(load()), OpenAPIGeneratorOptions.class); - - return deepCopy.toBuilder(); - } catch (JsonProcessingException e) { - throw new RuntimeException(e); - } - } - - /** - * Determines if the Generator should generate any Single Get Endpoints. Returns true if - * {@link SingleGetOptions#generating} is set to true or - * {@link SingleGetOptions#generatingFor} is set to true for any type - * @return true if the Generator should generate any Single Get Endpoints, false otherwise - */ - @JsonIgnore - public boolean isGeneratingSingleGet() { - return singleGet != null && (singleGet.isGenerating() || singleGet.getGeneratingFor().values().stream().anyMatch(value -> value)); - } + OpenAPIGeneratorOptions options = mapper.readValue(inputStream, OpenAPIGeneratorOptions.class); - /** - * Determines if the Generator should generate any List Get Endpoints. Returns true if - * {@link ListGetOptions#generating} is set to true or - * {@link ListGetOptions#generatingFor} is set to true for any type - * @return true if the Generator should generate any List Get Endpoints, false otherwise - */ - @JsonIgnore - public boolean isGeneratingListGet() { - return listGet != null && (listGet.isGenerating() || listGet.getGeneratingFor().values().stream().anyMatch(value -> value)); - } + options.validate() ; - /** - * Determines if the Generator should generate any Search Post or Get Endpoints. Returns true if - * {@link SearchOptions#generating} is set to true or - * {@link SearchOptions#generatingFor} is set to true for any type - * @return true if the Generator should generate any Search Post or Get Endpoints, false otherwise - */ - @JsonIgnore - public boolean isGeneratingSearch() { - return search != null && (search.isGenerating() || search.getGeneratingFor().values().stream().anyMatch(value -> value)); + return options ; } - /** - * Determines if the Generator should generate any Post Endpoints. Returns true if - * {@link PostOptions#generating} is set to true or - * {@link PostOptions#generatingFor} is set to true for any type - * @return true if the Generator should generate any Post Endpoints, false otherwise - */ - @JsonIgnore - public boolean isGeneratingPost() { - return post != null && (post.isGenerating() || post.getGeneratingFor().values().stream().anyMatch(value -> value)); + public void validate() { + super.validate() ; + + assert singleGet != null : "Single Get Endpoint Options are null"; + assert listGet != null : "List Get Endpoint Options are null"; + assert post != null : "Post Endpoint Options are null"; + assert put != null : "Put Endpoint Options are null"; + assert delete != null : "Delete Endpoint Options are null"; + assert search != null : "Search Endpoint Options are null"; + assert ids != null : "Id Options are null"; + + singleGet.validate() ; + listGet.validate() ; + post.validate() ; + put.validate() ; + delete.validate() ; + search.validate() ; + ids.validate() ; + + assert generateNewRequestFor != null : "'generateNewRequestFor' option is null" ; + assert newRequestNameFormat != null : "'newRequestNameFormat' option is null" ; + assert singleResponseNameFormat != null : "'singleResponseNameFormat' option is null" ; + assert listResponseNameFormat != null : "'listResponseNameFormat' option is null" ; + assert searchRequestNameFormat != null : "'searchRequestNameFormat' option is null" ; + assert pathItemNameFor != null : "'pathItemNameFor' option is null" ; } /** - * Determines if the Generator should generate any Put Endpoints. Returns true if - * {@link PutOptions#generating} is set to true or - * {@link PutOptions#generatingFor} is set to true for any type - * @return true if the Generator should generate any Put Endpoints, false otherwise + * Determines if the Generator should generate a separate specification per module. + * @return true if the Generator should generate a separate specification per module, false otherwise */ @JsonIgnore - public boolean isGeneratingPut() { - return put != null && (put.isGenerating() || put.getGeneratingFor().values().stream().anyMatch(value -> value)); - } - - /** - * Determines if the Generator should generate any Delete Endpoints. Returns true if - * {@link DeleteOptions#generating} is set to true or - * {@link DeleteOptions#generatingFor} is set to true for any type - * @return true if the Generator should generate any Delete Endpoints, false otherwise - */ - @JsonIgnore - public boolean isGeneratingDelete() { - return delete != null && (delete.isGenerating() || delete.getGeneratingFor().values().stream().anyMatch(value -> value)); + public boolean isSeparatingByModule() { + return separateByModule ; } /** * Determines if the Generator should generate any Endpoints without an ID parameter. Returns true if - * {@link #isGeneratingListGet()} or {@link #isGeneratingPost()} is set to true + * {@link ListGetOptions#isGenerating()} ()} or {@link PostOptions#isGenerating()} is set to true * @return true if the Generator should generate any Endpoints without an ID parameter, false otherwise */ @JsonIgnore public boolean isGeneratingEndpoint() { - return isGeneratingListGet() || isGeneratingPost(); - } - - /** - * Determines if the Generator should generate any Endpoints with an ID parameter. Returns true if - * {@link #isGeneratingSingleGet()} or {@link #isGeneratingPut()} or {@link #isGeneratingDelete()} is set to true - * @return true if the Generator should generate any Endpoints with an ID parameter, false otherwise - */ - @JsonIgnore - public boolean isGeneratingEndpointWithId() { - return isGeneratingSingleGet() || isGeneratingPut() || isGeneratingDelete(); - } - - /** - * Determines if the Generator should generate any Search Post or Get Endpoints. Returns true if - * {@link SearchOptions#generating} is set to true or - * {@link SearchOptions#generatingFor} is set to true for any type - * @return true if the Generator should generate any Search Post or Get Endpoints, false otherwise - */ - @JsonIgnore - public boolean isGeneratingSearchEndpoint() { - return search != null && (search.isGenerating() || search.getGeneratingFor().values().stream().anyMatch(value -> value)); - } - - /** - * Determines if the Generator should generate the Single Get Endpoint for a specific Primary Model. Returns true if - * {@link SingleGetOptions#generatingFor} is set to true for the specified type - * @param name the name of the Primary Model - * @return true if the Generator should generate the Single Get Endpoint for a specific Primary Model, false otherwise - */ - @JsonIgnore - public boolean isGeneratingSingleGetEndpointFor(String name) { - return singleGet != null && singleGet.generatingFor.getOrDefault(name, singleGet.isGenerating()) ; - } - - /** - * Determines if the Generator should generate the List Get Endpoint for a specific Primary Model. Returns true if - * {@link ListGetOptions#generatingFor} is set to true for the specified type - * @param name the name of the Primary Model - * @return true if the Generator should generate the List Get Endpoint for a specific Primary Model, false otherwise - */ - @JsonIgnore - public boolean isGeneratingListGetEndpointFor(String name) { - return listGet != null && listGet.generatingFor.getOrDefault(name, listGet.isGenerating()) ; + return listGet.isGenerating() || post.isGenerating(); } /** - * Determines if the Generator should generate the Post Endpoint for a specific Primary Model. Returns true if - * {@link PostOptions#generatingFor} is set to true for the specified type + * Determines if the Generator should generate the Endpoints without an ID parameter for a specific Primary Model. Returns true if + * {@link ListGetOptions#isGeneratingFor(String)} or {@link PostOptions#isGeneratingFor(String)} is set to true * @param name the name of the Primary Model - * @return true if the Generator should generate the Post Endpoint for a specific Primary Model, false otherwise + * @return true if the Generator should generate the Endpoints without an ID parameter for a specific Primary Model, false otherwise */ @JsonIgnore - public boolean isGeneratingPostEndpointFor(String name) { - return post != null && post.generatingFor.getOrDefault(name, post.isGenerating()) ; + public boolean isGeneratingEndpointFor(@NonNull String name) { + return listGet.isGeneratingFor(name) || post.isGeneratingFor(name) ; } /** - * Determines if the Generator should generate the Put Endpoint for a specific Primary Model. Returns true if - * {@link PutOptions#generatingFor} is set to true for the specified type - * @param name the name of the Primary Model - * @return true if the Generator should generate the Put Endpoint for a specific Primary Model, false otherwise + * Determines if the Generator should generate the Endpoints without an ID parameter for a specific Primary Model. Returns true if + * {@link ListGetOptions#isGeneratingFor(String)} or {@link PostOptions#isGeneratingFor(String)} is set to true + * @param type the Primary Model + * @return true if the Generator should generate the Endpoints without an ID parameter for a specific Primary Model, false otherwise */ @JsonIgnore - public boolean isGeneratingPutEndpointFor(String name) { - return put != null && put.generatingFor.getOrDefault(name, put.isGenerating()) ; + public boolean isGeneratingEndpointFor(@NonNull BrAPIType type) { + return isGeneratingEndpointFor(type.getName()) ; } /** - * Determines if the Generator should generate the Delete Endpoint for a specific Primary Model. Returns true if - * {@link PostOptions#generatingFor} is set to true for the specified type - * @param name the name of the Primary Model - * @return true if the Generator should generate the Delete Endpoint for a specific Primary Model, false otherwise + * Determines if the Generator should generate any Endpoints with an ID parameter. Returns true if + * {@link SingleGetOptions#isGenerating()} or {@link PutOptions#isGenerating()} or + * {@link DeleteOptions#isGenerating()} is set to true + * @return true if the Generator should generate any Endpoints without an ID parameter, false otherwise */ @JsonIgnore - public boolean isGeneratingDeleteEndpointFor(String name) { - return delete != null && delete.generatingFor.getOrDefault(name, delete.isGenerating()) ; + public boolean isGeneratingEndpointWithId() { + return singleGet.isGenerating() || put.isGenerating() || delete.isGenerating() ; } /** - * Determines if the Generator should generate the Search Post and Get Endpoint for a specific Primary Model. - * Returns true if - * {@link SearchOptions#generatingFor} is set to true for the specified type + * Determines if the Generator should generate the Endpoints with an ID parameter for a specific Primary Model. Returns true if + * {@link SingleGetOptions#isGeneratingFor(String)} or {@link PutOptions#isGeneratingFor(String)} or + * {@link DeleteOptions#isGeneratingFor(String)}is set to true * @param name the name of the Primary Model - * @return true if the Generator should generate the Search Post and Get Endpoint for a specific Primary Model, false otherwise + * @return true if the Generator should generate the Endpoints with an ID parameter for a specific Primary Model, false otherwise */ @JsonIgnore - public boolean isGeneratingSearchEndpointFor(String name) { - return search != null && search.getGeneratingFor().getOrDefault(name, isGeneratingSearch()) ; + public boolean isGeneratingEndpointNameWithIdFor(@NonNull String name) { + return singleGet.isGeneratingFor(name) || put.isGeneratingFor(name) || delete.isGeneratingFor(name) ; } /** - * Determines if the Generator should generate the Endpoints without an ID parameter for a specific Primary Model. Returns true if - * {@link #isGeneratingListGetEndpointFor(String)} or {@link #isGeneratingPostEndpointFor(String)} is set to true - * @param name the name of the Primary Model - * @return true if the Generator should generate the Endpoints without an ID parameter for a specific Primary Model, false otherwise + * Determines if the Generator should generate the Endpoints with an ID parameter for a specific Primary Model. Returns true if + * {@link SingleGetOptions#isGeneratingFor(String)} or {@link PutOptions#isGeneratingFor(String)} or + * {@link DeleteOptions#isGeneratingFor(String)}is set to true + * @param type the Primary Model + * @return true if the Generator should generate the Endpoints with an ID parameter for a specific Primary Model, false otherwise */ @JsonIgnore - public boolean isGeneratingEndpointFor(String name) { - return isGeneratingListGetEndpointFor(name ) || isGeneratingPostEndpointFor(name) ; + public final boolean isGeneratingEndpointNameWithIdFor(@NonNull BrAPIType type) { + return isGeneratingEndpointNameWithIdFor(type.getName()) ; } /** - * Determines if the Generator should generate the Endpoints with an ID parameter for a specific Primary Model. Returns true if - * {@link #isGeneratingSingleGetEndpointFor(String)} or {@link #isGeneratingPutEndpointFor(String)} or - * {@link #isGeneratingDeleteEndpointFor(String)}is set to true + * Determines if the Generator should generate a NewRequest schema, separate from the standard schema for a specific Primary Model. + * For example if set to true for the model 'Study' the generator will create the NewStudyRequest schema and the 'Study' schema, + * whereas if set false generator will create only create the 'Study' schema * @param name the name of the Primary Model - * @return true if the Generator should generate the Endpoints with an ID parameter for a specific Primary Model, false otherwise + * @return true if the Generator should generate a NewRequest schema, separate from the standard schema for a specific Primary Model, false otherwise */ @JsonIgnore - public boolean isGeneratingEndpointNameWithIdFor(String name) { - return isGeneratingSingleGetEndpointFor(name ) || isGeneratingPutEndpointFor(name) || isGeneratingDeleteEndpointFor(name) ; + public boolean isGeneratingNewRequestFor(@NonNull String name) { + return generateNewRequestFor.getOrDefault(name, generateNewRequest) ; } /** * Determines if the Generator should generate a NewRequest schema, separate from the standard schema for a specific Primary Model. - * For example if set to true for the model 'Study' the generator will create the NewStudyRequest schema and the 'Study' schema, + * For example if set to true for the model 'Study' the generator will create the NewStudyRequest schema and the 'Study' schema, * whereas if set false generator will create only create the 'Study' schema - * @param name the name of the Primary Model + * @param type the Primary Model * @return true if the Generator should generate a NewRequest schema, separate from the standard schema for a specific Primary Model, false otherwise */ @JsonIgnore - public boolean isGeneratingNewRequestFor(String name) { - return creatingNewRequestFor.getOrDefault(name, creatingNewRequest) ; + public final boolean isGeneratingNewRequestFor(@NonNull BrAPIType type) { + return isGeneratingNewRequestFor(type.getName()) ; } /** @@ -313,46 +242,58 @@ public boolean isGeneratingNewRequestFor(String name) { * @return the NewRequest schema name for a specific Primary Model */ @JsonIgnore - public String getNewRequestNameFor(String name) { + public String getNewRequestNameFor(@NonNull String name) { return String.format(newRequestNameFormat, name) ; } /** - * Determines if the Generator should generate the List Response for a specific Primary Model. - * @param name the name of the Primary Model - * @return true if the Generator generate the List Response for a specific Primary Model, false otherwise + * Gets the name for the NewRequest schema for a specific Primary Model + * @param type the Primary Model + * @return the NewRequest schema name for a specific Primary Model */ - public boolean isGeneratingListResponseFor(String name) { - return listGet != null && listGet.isGeneratingFor(name) ; + @JsonIgnore + public final String getNewRequestNameFor(@NonNull BrAPIType type) { + return getNewRequestNameFor(type.getName()) ; } /** - * Gets the name for the Single Response for a specific Primary Model + * Gets the name for the Single Response schema for a specific Primary Model * @param name the name of the Primary Model - * @return the Single Response name for a specific Primary Model + * @return the Single Response schema name for a specific Primary Model */ @JsonIgnore - public String getSingleResponseNameFor(String name) { + public String getSingleResponseNameFor(@NonNull String name) { return String.format(singleResponseNameFormat, name) ; } + /** + * Gets the name for the Single Response schema for a specific Primary Model + * @param type the Primary Model + * @return the Single Response schema name for a specific Primary Model + */ + @JsonIgnore + public final String getSingleResponseNameFor(@NonNull BrAPIType type) { + return getSingleResponseNameFor(type.getName()) ; + } + /** * Gets the name for the List Response for a specific Primary Model * @param name the name of the Primary Model * @return the List Response name for a specific Primary Model */ @JsonIgnore - public String getListResponseNameFor(String name) { + public final String getListResponseNameFor(@NonNull String name) { return String.format(listResponseNameFormat, name) ; } /** - * Determines if the Generator should generate the Search Request schema for a specific Primary Model. - * @param name the name of the Primary Model - * @return true if the Generator generate the Search Request schema for a specific Primary Model, false otherwise + * Gets the name for the List Response for a specific Primary Model + * @param type the Primary Model + * @return the List Response name for a specific Primary Model */ - public boolean isGeneratingSearchRequestFor(String name) { - return search != null && search.isGeneratingFor(name) ; + @JsonIgnore + public final String getListResponseNameFor(@NonNull BrAPIType type) { + return getListResponseNameFor(type.getName()) ; } /** @@ -361,18 +302,18 @@ public boolean isGeneratingSearchRequestFor(String name) { * @return the Search Request schema name for a specific Primary Model */ @JsonIgnore - public String getSearchRequestNameFor(String name) { + public final String getSearchRequestNameFor(@NonNull String name) { return String.format(searchRequestNameFormat, name) ; } /** - * Gets the Pluralise name for a specific Primary Model - * @param name the name of the Primary Model - * @return the Pluralise name for a specific Primary Model + * Gets the name for the Search Request schema for a specific Primary Model + * @param type the Primary Model + * @return the Search Request schema name for a specific Primary Model */ @JsonIgnore - public String getPluralFor(String name) { - return toPlural(name) ; + public final String getSearchRequestNameFor(@NonNull BrAPIType type) { + return getSearchRequestNameFor(type.getName()) ; } /** @@ -381,12 +322,34 @@ public String getPluralFor(String name) { * @return the Pluralise name for a specific Primary Model */ @JsonIgnore - public String getSingularForProperty(String propertyName) { + public final String getSingularForProperty(@NonNull String propertyName) { return toSingular(propertyName) ; } /** - * + * Gets the path item name for a specific Primary Model + * @param name the name of the Primary Model + * @return the Pluralised name for a specific Primary Model + */ + public String getPathItemNameFor(String name) { + return String.format("/%s", toParameterCase(getPluralFor(name))); + } + + /** + * Gets the path item name for a specific Primary Model + * @param type the Primary Model + * @return the path item name for a specific Primary Model + */ + public String getPathItemNameFor(BrAPIType type) { + return pathItemNameFor.getOrDefault(type.getName(), String.format("/%s", toParameterCase(getPluralFor(type)))); + } + + /** + * Gets the path item with id name for a specific Primary Model + * @param type the Primary Model + * @return the path item name for a specific Primary Model */ - public static class OpenAPIGeneratorOptionsBuilder {} + public String getPathItemWithIdNameFor(BrAPIType type) { + return String.format("%s/{%s}", getPathItemNameFor(type), ids.getIDParameterFor(type)); + } } diff --git a/java/core/src/main/java/org/brapi/schematools/core/openapi/options/PostOptions.java b/java/core/src/main/java/org/brapi/schematools/core/openapi/options/PostOptions.java index 375268c..1d9a729 100644 --- a/java/core/src/main/java/org/brapi/schematools/core/openapi/options/PostOptions.java +++ b/java/core/src/main/java/org/brapi/schematools/core/openapi/options/PostOptions.java @@ -1,36 +1,7 @@ package org.brapi.schematools.core.openapi.options; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.*; - -import java.util.HashMap; -import java.util.Map; - /** * Provides options for the generation of Post Endpoints */ -@Getter -@Setter(AccessLevel.PRIVATE) -@Builder -@NoArgsConstructor(access = AccessLevel.PRIVATE) -@AllArgsConstructor(access = AccessLevel.PRIVATE) -public class PostOptions { - @JsonProperty("generate") - boolean generating; - String summaryFormat; - String descriptionFormat; - @JsonProperty("generateFor") - @Builder.Default - Map generatingFor = new HashMap<>(); - - /** - * Determines if the Post Endpoint is generated for a specific primary model - * @param name the name of the primary model - * @return true if the Post Endpoint is generated for a specific primary model, false otherwise - */ - @JsonIgnore - public boolean isGeneratingFor(String name) { - return generatingFor.getOrDefault(name, generating) ; - } +public class PostOptions extends AbstractOpenAPIOptions { } diff --git a/java/core/src/main/java/org/brapi/schematools/core/openapi/options/PutOptions.java b/java/core/src/main/java/org/brapi/schematools/core/openapi/options/PutOptions.java index cfd3e9d..efbaa9d 100644 --- a/java/core/src/main/java/org/brapi/schematools/core/openapi/options/PutOptions.java +++ b/java/core/src/main/java/org/brapi/schematools/core/openapi/options/PutOptions.java @@ -1,36 +1,8 @@ package org.brapi.schematools.core.openapi.options; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.*; - -import java.util.HashMap; -import java.util.Map; - /** * Provides options for the generation of Put Endpoints */ -@Getter -@Setter(AccessLevel.PRIVATE) -@Builder -@NoArgsConstructor(access = AccessLevel.PRIVATE) -@AllArgsConstructor(access = AccessLevel.PRIVATE) -public class PutOptions { - @JsonProperty("generate") - boolean generating; - String summaryFormat; - String descriptionFormat; - @JsonProperty("generateFor") - @Builder.Default - Map generatingFor = new HashMap<>(); +public class PutOptions extends AbstractOpenAPIOptions { - /** - * Determines if the Put Endpoint is generated for a specific primary model - * @param name the name of the primary model - * @return true if the Put Endpoint is generated for a specific primary model, false otherwise - */ - @JsonIgnore - public boolean isGeneratingFor(String name) { - return generatingFor.getOrDefault(name, generating) ; - } } diff --git a/java/core/src/main/java/org/brapi/schematools/core/openapi/options/SearchOptions.java b/java/core/src/main/java/org/brapi/schematools/core/openapi/options/SearchOptions.java index 25b86e0..5f4fec4 100644 --- a/java/core/src/main/java/org/brapi/schematools/core/openapi/options/SearchOptions.java +++ b/java/core/src/main/java/org/brapi/schematools/core/openapi/options/SearchOptions.java @@ -1,37 +1,46 @@ package org.brapi.schematools.core.openapi.options; import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.*; +import lombok.AccessLevel; +import lombok.Getter; +import lombok.Setter; +import org.brapi.schematools.core.model.BrAPIType; -import java.util.HashMap; -import java.util.Map; +import static org.brapi.schematools.core.utils.StringUtils.toParameterCase; /** * Provides options for the generation of Search Post and Get Endpoints */ -@Getter -@Setter(AccessLevel.PRIVATE) -@Builder -@NoArgsConstructor(access = AccessLevel.PRIVATE) -@AllArgsConstructor(access = AccessLevel.PRIVATE) -public class SearchOptions { - @JsonProperty("generate") - boolean generating; - String summaryFormat; - String submitDescriptionFormat; - String retrieveDescriptionFormat; - @JsonProperty("generateFor") - @Builder.Default - Map generatingFor = new HashMap<>(); +@Getter(AccessLevel.PRIVATE) +@Setter +public class SearchOptions extends AbstractOpenAPIOptions { + private String submitDescriptionFormat; + private String retrieveDescriptionFormat; + + public void validate() { + super.validate(); + assert submitDescriptionFormat != null : String.format("'submitDescriptionFormat' option on %s is null", this.getClass().getSimpleName()); + assert retrieveDescriptionFormat != null : String.format("'retrieveDescriptionFormat' option on %s is null", this.getClass().getSimpleName()); + } + + + /** + * Gets the submit description for a specific primary model + * @param type the primary model + * @return the submit description for a specific primary model + */ + @JsonIgnore + public final String getSubmitDescriptionFormat(BrAPIType type) { + return String.format(submitDescriptionFormat, type.getName(), toParameterCase(type.getName())) ; + } /** - * Determines if the Search Post and Get Endpoints are generated for a specific primary model - * @param name the name of the primary model - * @return true if the Search Post and Get Endpoints are generated for a specific primary model, false otherwise + * Gets the retrieve description for a specific primary model + * @param type the primary model + * @return the retrieve description for a specific primary model */ @JsonIgnore - public boolean isGeneratingFor(String name) { - return generatingFor.getOrDefault(name, generating) ; + public final String getRetrieveDescriptionFormat(BrAPIType type) { + return String.format(retrieveDescriptionFormat, type.getName(), toParameterCase(type.getName())) ; } -} +} \ No newline at end of file diff --git a/java/core/src/main/java/org/brapi/schematools/core/openapi/options/SingleGetOptions.java b/java/core/src/main/java/org/brapi/schematools/core/openapi/options/SingleGetOptions.java index 694f328..c74895e 100644 --- a/java/core/src/main/java/org/brapi/schematools/core/openapi/options/SingleGetOptions.java +++ b/java/core/src/main/java/org/brapi/schematools/core/openapi/options/SingleGetOptions.java @@ -1,36 +1,8 @@ package org.brapi.schematools.core.openapi.options; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.*; - -import java.util.HashMap; -import java.util.Map; - /** * Provides options for the generation of Single Get Endpoints */ -@Getter -@Setter(AccessLevel.PRIVATE) -@Builder -@NoArgsConstructor(access = AccessLevel.PRIVATE) -@AllArgsConstructor(access = AccessLevel.PRIVATE) -public class SingleGetOptions { - @JsonProperty("generate") - boolean generating; - String summaryFormat; - String descriptionFormat; - @JsonProperty("generateFor") - @Builder.Default - Map generatingFor = new HashMap<>(); +public class SingleGetOptions extends AbstractOpenAPIOptions { - /** - * Determines if the Single Get Endpoint is generated for a specific primary model - * @param name the name of the primary model - * @return true if the Single Get Endpoint is generated for a specific primary model, false otherwise - */ - @JsonIgnore - public boolean isGeneratingFor(String name) { - return generatingFor.getOrDefault(name, generating) ; - } } diff --git a/java/core/src/main/java/org/brapi/schematools/core/options/AbstractGeneratorOptions.java b/java/core/src/main/java/org/brapi/schematools/core/options/AbstractGeneratorOptions.java new file mode 100644 index 0000000..c27390d --- /dev/null +++ b/java/core/src/main/java/org/brapi/schematools/core/options/AbstractGeneratorOptions.java @@ -0,0 +1,57 @@ +package org.brapi.schematools.core.options; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.AccessLevel; +import lombok.NonNull; +import lombok.Setter; +import org.brapi.schematools.core.model.BrAPIType; + +import java.util.HashMap; +import java.util.Map; + +import static org.brapi.schematools.core.utils.StringUtils.toPlural; + +public class AbstractGeneratorOptions { + + @Setter(AccessLevel.PRIVATE) + private Map pluralFor = new HashMap<>(); + public void validate() { + assert pluralFor != null : String.format("'pluralFor' option on %s is null", this.getClass().getSimpleName()); + } + + /** + * Gets the Pluralised name for a specific Primary Model. For example plural + * name of Study, would be 'Studies' by default. Use {@link #setIDParameterFor} to override this value. + * @param name the name of the Primary Model + * @return the pluralised name for a specific Primary Model + */ + @JsonIgnore + public final String getPluralFor(@NonNull String name) { + return pluralFor.getOrDefault(name, toPlural(name)) ; + } + + /** + * Gets the pluralised name for a specific Primary Model. For example plural + * name of Study, would be 'Studies' by default. Use {@link #setIDParameterFor} to override this value. + * @param type the Primary Model + * @return the pluralised name for a specific Primary Model + */ + @JsonIgnore + public final String getPluralFor(@NonNull BrAPIType type) { + return getPluralFor(type.getName()) ; + } + + /** + * Sets the pluralised name for a specific primary model. For example the id parameter (or field) + * name of Study, would be 'studyDbiId' by default. + * @param name the name of the primary model + * @param pluralisedName the pluralised name for a specific primary model. + * @return the options for chaining + */ + @JsonIgnore + public AbstractGeneratorOptions setPluralFor(String name, String pluralisedName) { + pluralFor.put(name, pluralisedName) ; + + return this ; + } +} diff --git a/java/core/src/main/java/org/brapi/schematools/core/options/AbstractOptions.java b/java/core/src/main/java/org/brapi/schematools/core/options/AbstractOptions.java new file mode 100644 index 0000000..fb70a4c --- /dev/null +++ b/java/core/src/main/java/org/brapi/schematools/core/options/AbstractOptions.java @@ -0,0 +1,103 @@ +package org.brapi.schematools.core.options; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.*; +import org.brapi.schematools.core.model.BrAPIType; + +import java.util.HashMap; +import java.util.Map; + + +/** + * Provides general options + */ +@Getter(AccessLevel.PRIVATE) +@Setter +@NoArgsConstructor(access = AccessLevel.PROTECTED) +@AllArgsConstructor(access = AccessLevel.PROTECTED) +public abstract class AbstractOptions { + private boolean generate; + private String descriptionFormat; + @Setter(AccessLevel.PRIVATE) + private Map generateFor = new HashMap<>(); + + public void validate() { + assert descriptionFormat != null : String.format("'descriptionFormat' option on %s is null", this.getClass().getSimpleName()); + assert generateFor != null : String.format("'generateFor' option on %s is null", this.getClass().getSimpleName()); + } + + /** + * Determines if the Endpoint/Query/Mutation is generated for any primary model. Returns true if + * {@link AbstractOptions#generate} is set to true or + * {@link AbstractOptions#generateFor} is set to true for any type + * @return true if the Generator should generate any Endpoints/Queries/Mutations, false otherwise + */ + @JsonIgnore + public final boolean isGenerating() { + return generate || generateFor.values().stream().anyMatch(value -> value); + } + + /** + * Determines if the Endpoint/Query/Mutation is generated for a specific primary model + * @param name the name of the primary model + * @return true if the Endpoint/Query/Mutation is generated for a specific primary model, false otherwise + */ + @JsonIgnore + public final boolean isGeneratingFor(@NonNull String name) { + return generateFor.getOrDefault(name, generate) ; + } + + /** + * Determines if the Endpoint/Query/Mutation is generated for a specific primary model + * @param type the primary model + * @return true if the Endpoint/Query/Mutation is generated for a specific primary model, false otherwise + */ + @JsonIgnore + public final boolean isGeneratingFor(@NonNull BrAPIType type) { + return isGeneratingFor(type.getName()) ; + } + + /** + * Gets the description for a specific primary model + * @param name the name of the primary model + * @return the description for a specific primary model + */ + @JsonIgnore + public final String getDescriptionFor(@NonNull String name) { + return String.format(descriptionFormat, name) ; + } + + /** + * Gets the description for a specific primary model + * @param type the primary model + * @return the description for a specific primary model + */ + @JsonIgnore + public final String getDescriptionFor(@NonNull BrAPIType type) { + return getDescriptionFor(type.getName()); + } + + /** + * Sets if the Endpoint/Query/Mutation is generated for a specific primary model. + * @param name the name of the primary model + * @param generate true if the Endpoint/Query/Mutation is generated for a specific primary model, false + * @return the options for chaining + */ + @JsonIgnore + public AbstractOptions setGenerateFor(String name, boolean generate) { + generateFor.put(name, generate) ; + + return this ; + } + + /** + * Sets if the Endpoint/Query/Mutation is generated for a specific primary model. + * @param generate true if the Endpoint/Query/Mutation is generated for a specific primary model, false + * @return the options for chaining + */ + @JsonIgnore + public AbstractOptions setGenerateFor(BrAPIType type, boolean generate) { + return setGenerateFor(type.getName(), generate) ; + } +} + diff --git a/java/core/src/main/java/org/brapi/schematools/core/utils/StringUtils.java b/java/core/src/main/java/org/brapi/schematools/core/utils/StringUtils.java index 0d26b01..4b9cbc8 100644 --- a/java/core/src/main/java/org/brapi/schematools/core/utils/StringUtils.java +++ b/java/core/src/main/java/org/brapi/schematools/core/utils/StringUtils.java @@ -14,7 +14,7 @@ public class StringUtils { private static final Set unpluralisables = ImmutableSet.of( "equipment", "information", "rice", "money", "species", "series", - "fish", "sheep", "deer", "analysis"); + "fish", "sheep", "deer"); private static final List singularisations = ImmutableList.of( replace("(.*)people$").with("$1person"), diff --git a/java/core/src/main/resources/graphql-options.yaml b/java/core/src/main/resources/graphql-options.yaml index 90f9422..d9231d9 100644 --- a/java/core/src/main/resources/graphql-options.yaml +++ b/java/core/src/main/resources/graphql-options.yaml @@ -1,16 +1,29 @@ +pluralFor: + AlleleMatrix: AlleleMatrix +input: + name: input + nameFormat: "%sInput" + typeNameFormat: "%sInput" queryType: - generate: true name: Query partitionedByCrop: true singleQuery: generate: true + pluralisingName: false + nameFormat: "%s" descriptionFormat: Returns a %s object by id + generateFor: + AlleleMatrix: false + Call: false + Cross: false + Event: false + MarkerPosition: false + PlannedCross: false listQuery: generate: true + pluralisingName: true + nameFormat: "%s" descriptionFormat: Returns %s objects - inputName: input - inputNameFormat: "%sInput" - inputTypeNameFormat: "%sInput" responseTypeNameFormat: "%sListResponse" dataFieldName: data pagedDefault: true @@ -19,20 +32,75 @@ queryType: input: BreedingMethod: false CrossingProject: true + generateFor: + AlleleMatrix: false pagingInputName: paging pageInputTypeName: PageInput pageTypeName: PageInfo pageFieldName: page searchQuery: generate: true + pluralisingName: true + nameFormat: "%sSearch" descriptionFormat: Returns %s objects + responseTypeNameFormat: "%sResponse" + searchIdFieldName: searchResultsDbId generateFor: + AlleleMatrix: false BreedingMethod: false Cross: false - CrossingProjects: false + CrossProject: false + Method: false + Ontology: false + Scale: false + Trait: false mutationType: - generate: false name: Mutation + createMutation: + generate: true + pluralisingName: false + nameFormat: create%s + descriptionFormat: Create a new %s + generateFor: + AlleleMatrix: false + Call: false + CallSet: false + Cross: false + Event: false + GenomeMap: false + MarkerPosition: false + Reference: false + Variant: false + updateMutation: + generate: true + pluralisingName: false + nameFormat: update%s + descriptionFormat: Update the details for an existing %s + generateFor: + AlleleMatrix: false + Call: false + CallSet: false + Cross: false + Event: false + GenomeMap: false + MarkerPosition: false + Reference: false + Variant: false + deleteMutation: + generate: false + pluralisingName: true + nameFormat: delete%s + descriptionFormat: Delete existing %s + generateFor: + AlleleMatrix: false + Call: false + CallSet: false + Event: false + GenomeMap: false + MarkerPosition: false + Reference: false + Variant: false + VariantSet: false ids: useIDType: true nameFormat: "%sDbId" \ No newline at end of file diff --git a/java/core/src/main/resources/openapi-options.yaml b/java/core/src/main/resources/openapi-options.yaml index 15414ae..0cbbd2d 100644 --- a/java/core/src/main/resources/openapi-options.yaml +++ b/java/core/src/main/resources/openapi-options.yaml @@ -1,22 +1,53 @@ separateByModule: false -createNewRequest: true -createNewRequestFor: +generateNewRequest: true +generateNewRequestFor: + AlleleMatrix: false + BreedingMethod: false + Call: false + CallSet: false + Event: false + GenomeMap: false + MarkerPosition: false + Reference: false + PedigreeNode: false + PlannedCross: false Season: false + Variant: false + VariantSet: false newRequestNameFormat: "%sNewRequest" singleResponseNameFormat: "%sSingleResponse" listResponseNameFormat: "%sListResponse" searchRequestNameFormat: "%sSearchRequest" +pluralFor: + AlleleMatrix: AlleleMatrix +pathItemNameFor: + PedigreeNode: pedigrees singleGet: generate: true summaryFormat: Get the details of a specific %s descriptionFormat: Get details for a %s + generateFor: + AlleleMatrix: false + Call: false + Cross: false + Event: false + MarkerPosition: false + PlannedCross: false listGet: generate: true summaryFormat: Get a filtered list of %s descriptionFormat: Get a list of %s + generateFor: + AlleleMatrix: false + pagedDefault: true + paged: + BreedingMethod: false + inputFor: + BreedingMethod: false search: generate: true summaryFormat: Submit a search request for `%s` + descriptionFormat: Submit a search request for `%s`t submitDescriptionFormat: |- Submit a search request for `%s`
Search requests allow a client to send a complex query for data. However, the server may not respond with the search results immediately. @@ -30,17 +61,59 @@ search: If a server needs more time to process the request, it might respond with a `searchResultsDbId`. Use this endpoint to retrieve the results of the search.
Review the Search Services documentation for additional implementation details. + generateFor: + AlleleMatrix: false + BreedingMethod: false + Cross: false + CrossProject: false + Method: false + Ontology: false + Scale: false + Trait: false post: generate: true summaryFormat: Create new %s descriptionFormat: Add new %s to database + generateFor: + AlleleMatrix: false + Call: false + CallSet: false + Event: false + GenomeMap: false + MarkerPosition: false + Reference: false + Variant: false + VariantSet: false put: generate: true summaryFormat: Update the details for an existing %s descriptionFormat: Update the details for an existing %s + generateFor: + AlleleMatrix: false + Call: false + CallSet: false + Cross: false + Event: false + GenomeMap: false + MarkerPosition: false + Reference: false + Variant: false delete: generate: false summaryFormat: Delete an existing %s descriptionFormat: Delete existing %s + generateFor: + AlleleMatrix: false + Call: false + CallSet: false + Event: false + GenomeMap: false + MarkerPosition: false + Reference: false + Variant: false + VariantSet: false ids: - nameFormat: "%sDbId" \ No newline at end of file + nameFormat: "%sDbId" + parameterFor: + GermplasmAttribute: attributeDbId + GermplasmAttributeValue: attributeValueDbId \ No newline at end of file diff --git a/java/core/src/test/java/org/brapi/schematools/core/brapischema/BrAPISchemaReaderTest.java b/java/core/src/test/java/org/brapi/schematools/core/brapischema/BrAPISchemaReaderTest.java index cbcb13c..20482a7 100644 --- a/java/core/src/test/java/org/brapi/schematools/core/brapischema/BrAPISchemaReaderTest.java +++ b/java/core/src/test/java/org/brapi/schematools/core/brapischema/BrAPISchemaReaderTest.java @@ -1,7 +1,6 @@ package org.brapi.schematools.core.brapischema; import org.brapi.schematools.core.model.BrAPIClass; -import org.brapi.schematools.core.model.BrAPIObjectType; import org.junit.jupiter.api.Test; import java.nio.charset.Charset; @@ -32,35 +31,35 @@ void readDirectories() { getResult().stream().collect(Collectors.toMap(BrAPIClass::getName, Function.identity())); assertNotNull(schemas); - assertEquals(54, schemas.size()); + assertEquals(96, schemas.size()); BrAPIClass trialSchema = schemas.get("Trial"); assertNotNull(trialSchema); assertEquals("Trial", trialSchema.getName()); assertEquals("BrAPI-Core", trialSchema.getModule()); assertNotNull(trialSchema.getMetadata()); - assertFalse(trialSchema.getMetadata().isPrimaryModel()); + assertTrue(trialSchema.getMetadata().isPrimaryModel()); BrAPIClass sampleSchema = schemas.get("Sample"); assertNotNull(sampleSchema); assertEquals("Sample", sampleSchema.getName()); assertEquals("BrAPI-Genotyping", sampleSchema.getModule()); assertNotNull(sampleSchema.getMetadata()); - assertFalse(sampleSchema.getMetadata().isPrimaryModel()); + assertTrue(sampleSchema.getMetadata().isPrimaryModel()); BrAPIClass germplasmSchema = schemas.get("Germplasm"); assertNotNull(germplasmSchema); assertEquals("Germplasm", germplasmSchema.getName()); assertEquals("BrAPI-Germplasm", germplasmSchema.getModule()); assertNotNull(germplasmSchema.getMetadata()); - assertFalse(germplasmSchema.getMetadata().isPrimaryModel()); + assertTrue(germplasmSchema.getMetadata().isPrimaryModel()); BrAPIClass traitSchema = schemas.get("Trait"); assertNotNull(traitSchema); assertEquals("Trait", traitSchema.getName()); assertEquals("BrAPI-Phenotyping", traitSchema.getModule()); assertNotNull(traitSchema.getMetadata()); - assertFalse(traitSchema.getMetadata().isPrimaryModel()); + assertTrue(traitSchema.getMetadata().isPrimaryModel()); BrAPIClass listType = schemas.get("ListType"); assertNotNull(listType); @@ -74,6 +73,7 @@ void readDirectories() { assertNull(listRequest.getModule()); assertNotNull(listRequest.getMetadata()); assertTrue(listRequest.getMetadata().isRequest()); + assertFalse(listRequest.getMetadata().isPrimaryModel()); } catch (Exception e) { e.printStackTrace(); @@ -95,14 +95,13 @@ void readSchemaPath() { assertEquals("Trial", trialSchema.getName()); assertEquals("BrAPI-Core", trialSchema.getModule()); assertNotNull(trialSchema.getMetadata()); - assertFalse(trialSchema.getMetadata().isPrimaryModel()); + assertTrue(trialSchema.getMetadata().isPrimaryModel()); BrAPIClass listTypeSchema = new BrAPISchemaReader(). readSchema(Path.of(ClassLoader.getSystemResource("BrAPI-Schema/BrAPI-Core/ListType.json").toURI()), "BrAPI-Core"). onFailDoWithResponse(response -> fail(response.getMessagesCombined(","))). getResult(); - assertNotNull(listTypeSchema); assertNotNull(listTypeSchema); @@ -143,7 +142,7 @@ void readSchemaString() { assertEquals("Trial", trialSchema.getName()); assertEquals("BrAPI-Core", trialSchema.getModule()); assertNotNull(trialSchema.getMetadata()); - assertFalse(trialSchema.getMetadata().isPrimaryModel()); + assertTrue(trialSchema.getMetadata().isPrimaryModel()); path = Paths.get(Objects.requireNonNull(this.getClass().getResource("/BrAPI-Schema/BrAPI-Core/ListType.json")).toURI()); @@ -171,6 +170,7 @@ void readSchemaString() { assertNull(listRequest.getModule()); assertNotNull(listRequest.getMetadata()); assertTrue(listRequest.getMetadata().isRequest()); + assertFalse(listRequest.getMetadata().isPrimaryModel()); } catch (Exception e) { e.printStackTrace(); fail(e.getMessage()); diff --git a/java/core/src/test/java/org/brapi/schematools/core/graphql/options/GraphQLGeneratorOptionsTest.java b/java/core/src/test/java/org/brapi/schematools/core/graphql/options/GraphQLGeneratorOptionsTest.java index 08029b1..3a9eb91 100644 --- a/java/core/src/test/java/org/brapi/schematools/core/graphql/options/GraphQLGeneratorOptionsTest.java +++ b/java/core/src/test/java/org/brapi/schematools/core/graphql/options/GraphQLGeneratorOptionsTest.java @@ -21,13 +21,6 @@ void load() { checkOptions(options); } - @Test - void defaultBuilder() { - GraphQLGeneratorOptions options = GraphQLGeneratorOptions.defaultBuilder().build(); - - checkOptions(options); - } - @Test void loadJson() { GraphQLGeneratorOptions options = null; @@ -58,19 +51,81 @@ private void checkOptions(GraphQLGeneratorOptions options) { assertNotNull(options); assertTrue(options.isGeneratingQueryType()); + + checkOptions(options.getIds()); + checkOptions(options.getQueryType()); + checkOptions(options.getMutationType()); + checkOptions(options.getInput()); + assertNotNull(options.getQueryType()); - assertTrue(options.getQueryType().isGenerating()); assertEquals("Query", options.getQueryType().getName()); assertNotNull(options.getQueryType().getSingleQuery()); - assertEquals("Returns a %s object by id", options.getQueryType().getSingleQuery().getDescriptionFormat()); - assertFalse(options.isGeneratingMutationType()); + assertTrue(options.isGeneratingMutationType()); assertNotNull(options.getMutationType()); - assertFalse(options.getMutationType().isGenerating()); assertEquals("Mutation", options.getMutationType().getName()); assertNotNull(options.getIds()); assertTrue(options.getIds().isUsingIDType()); - assertEquals("%sDbId", options.getIds().getNameFormat()); + } + + private void checkOptions(IdsOptions options) { + assertNotNull(options); + assertTrue(options.isUsingIDType()); + } + + private void checkOptions(QueryTypeOptions options) { + assertNotNull(options); + assertTrue(options.isPartitionedByCrop()); + assertEquals("Query", options.getName()); + checkOptions(options.getSingleQuery()) ; + checkOptions(options.getListQuery()) ; + checkOptions(options.getSearchQuery()) ; + } + + private void checkOptions(SingleQueryOptions options) { + assertNotNull(options); + assertTrue(options.isGenerating()); + assertEquals("Returns a Trial object by id", options.getDescriptionFor("Trial")); + } + + private void checkOptions(ListQueryOptions options) { + assertNotNull(options); + assertTrue(options.isGenerating()); + } + + private void checkOptions(SearchQueryOptions options) { + assertNotNull(options); + assertTrue(options.isGenerating()); + } + + private void checkOptions(MutationTypeOptions options) { + assertNotNull(options); + assertEquals("Mutation", options.getName()); + checkOptions(options.getCreateMutation()) ; + checkOptions(options.getUpdateMutation()) ; + checkOptions(options.getDeleteMutation()) ; + } + + private void checkOptions(CreateMutationOptions options) { + assertNotNull(options); + assertTrue(options.isGenerating()); + assertEquals("createTrial", options.getNameFor("Trial")); + } + + private void checkOptions(UpdateMutationOptions options) { + assertNotNull(options); + assertTrue(options.isGenerating()); + assertEquals("updateTrial", options.getNameFor("Trial")); + } + + private void checkOptions(DeleteMutationOptions options) { + assertNotNull(options); + assertFalse(options.isGenerating()); + assertEquals("deleteTrial", options.getNameFor("Trial")); + } + + private void checkOptions(InputOptions options) { + assertNotNull(options); } } \ No newline at end of file diff --git a/java/core/src/test/java/org/brapi/schematools/core/openapi/OpenAPIComponentsReaderTest.java b/java/core/src/test/java/org/brapi/schematools/core/openapi/OpenAPIComponentsReaderTest.java index d6216e4..2b0a211 100644 --- a/java/core/src/test/java/org/brapi/schematools/core/openapi/OpenAPIComponentsReaderTest.java +++ b/java/core/src/test/java/org/brapi/schematools/core/openapi/OpenAPIComponentsReaderTest.java @@ -24,7 +24,7 @@ void readComponents() { assertEquals(9, components.getParameters().size()); assertEquals(5, components.getResponses().size()); - assertEquals(10, components.getSchemas().size()); + assertEquals(9, components.getSchemas().size()); assertEquals(1, components.getSecuritySchemes().size()); } catch (Exception e) { diff --git a/java/core/src/test/java/org/brapi/schematools/core/openapi/OpenAPIGeneratorTest.java b/java/core/src/test/java/org/brapi/schematools/core/openapi/OpenAPIGeneratorTest.java index 590f62b..6a47a7f 100644 --- a/java/core/src/test/java/org/brapi/schematools/core/openapi/OpenAPIGeneratorTest.java +++ b/java/core/src/test/java/org/brapi/schematools/core/openapi/OpenAPIGeneratorTest.java @@ -23,7 +23,7 @@ class OpenAPIGeneratorTest { void generate() { Response> specifications; try { - specifications = new OpenAPIGenerator(OpenAPIGeneratorOptions.builder().separatingByModule(false).build()). + specifications = new OpenAPIGenerator(OpenAPIGeneratorOptions.load().setSeparateByModule(false)). generate(Path.of(ClassLoader.getSystemResource("BrAPI-Schema").toURI()), Path.of(ClassLoader.getSystemResource("OpenAPI-Components").toURI())); } catch (URISyntaxException e) { e.printStackTrace(); @@ -41,7 +41,7 @@ void generate() { void generateByModule() { Response> specifications; try { - specifications = new OpenAPIGenerator(OpenAPIGeneratorOptions.builder().separatingByModule(true).build()). + specifications = new OpenAPIGenerator(OpenAPIGeneratorOptions.load().setSeparateByModule(true)). generate(Path.of(ClassLoader.getSystemResource("BrAPI-Schema").toURI()), Path.of(ClassLoader.getSystemResource("OpenAPI-Components").toURI())); } catch (URISyntaxException e) { e.printStackTrace(); diff --git a/java/core/src/test/java/org/brapi/schematools/core/openapi/options/DeleteOptionsTest.java b/java/core/src/test/java/org/brapi/schematools/core/openapi/options/DeleteOptionsTest.java new file mode 100644 index 0000000..bbcc366 --- /dev/null +++ b/java/core/src/test/java/org/brapi/schematools/core/openapi/options/DeleteOptionsTest.java @@ -0,0 +1,38 @@ +package org.brapi.schematools.core.openapi.options; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + +class DeleteOptionsTest { + + DeleteOptions subject ; + @BeforeEach + void setUp() { + subject = OpenAPIGeneratorOptions.load().getDelete() ; + + subject.setGenerate(true); + } + + @Test + void isGenerating() { + assertTrue(subject.isGenerating()); + } + + @Test + void isGeneratingFor() { + assertTrue(subject.isGeneratingFor("Trial")); + assertTrue(subject.isGeneratingFor("BreedingMethod")); + assertFalse(subject.isGeneratingFor("AlleleMatrix")); + } + + @Test + void getSummaryFor() { + } + + @Test + void getDescriptionFor() { + } +} \ No newline at end of file diff --git a/java/core/src/test/java/org/brapi/schematools/core/openapi/options/ListGetOptionsTest.java b/java/core/src/test/java/org/brapi/schematools/core/openapi/options/ListGetOptionsTest.java new file mode 100644 index 0000000..c1259f4 --- /dev/null +++ b/java/core/src/test/java/org/brapi/schematools/core/openapi/options/ListGetOptionsTest.java @@ -0,0 +1,48 @@ +package org.brapi.schematools.core.openapi.options; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + +class ListGetOptionsTest { + + ListGetOptions subject ; + @BeforeEach + void setUp() { + subject = OpenAPIGeneratorOptions.load().getListGet() ; + } + + @Test + void isGenerating() { + assertTrue(subject.isGenerating()); + } + + @Test + void isGeneratingFor() { + assertTrue(subject.isGeneratingFor("Trial")); + assertTrue(subject.isGeneratingFor("BreedingMethod")); + assertFalse(subject.isGeneratingFor("AlleleMatrix")); + } + + @Test + void getSummaryFormat() { + } + + @Test + void getDescriptionFormat() { + } + + @Test + void isPagedDefault() { + } + + @Test + void getPaged() { + } + + @Test + void builder() { + } +} \ No newline at end of file diff --git a/java/core/src/test/java/org/brapi/schematools/core/openapi/options/OpenAPIGeneratorOptionsTest.java b/java/core/src/test/java/org/brapi/schematools/core/openapi/options/OpenAPIGeneratorOptionsTest.java index 78f5d39..54f0fd3 100644 --- a/java/core/src/test/java/org/brapi/schematools/core/openapi/options/OpenAPIGeneratorOptionsTest.java +++ b/java/core/src/test/java/org/brapi/schematools/core/openapi/options/OpenAPIGeneratorOptionsTest.java @@ -1,32 +1,31 @@ package org.brapi.schematools.core.openapi.options; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import java.io.IOException; import java.net.URISyntaxException; import java.nio.file.Path; +import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.fail; class OpenAPIGeneratorOptionsTest { - @Test - void load() { - OpenAPIGeneratorOptions options = OpenAPIGeneratorOptions.load(); - checkOptions(options); + @BeforeEach + void setUp() { } @Test - void defaultBuilder() { - OpenAPIGeneratorOptions options = OpenAPIGeneratorOptions.defaultBuilder().build(); + void load() { + OpenAPIGeneratorOptions options = OpenAPIGeneratorOptions.load(); checkOptions(options); } - @Test void loadJson() { OpenAPIGeneratorOptions options = null; @@ -53,25 +52,211 @@ void loadYaml() { checkOptions(options); } + @Test + void isGeneratingSingleGet() { + } + + @Test + void isGeneratingListGet() { + } + + @Test + void isGeneratingSearch() { + } + + @Test + void isGeneratingPost() { + } + + @Test + void isGeneratingPut() { + } + + @Test + void isGeneratingDelete() { + } + + @Test + void isGeneratingEndpoint() { + } + + @Test + void isGeneratingEndpointWithId() { + } + + @Test + void isGeneratingSearchEndpoint() { + } + + @Test + void isGeneratingSingleGetEndpointFor() { + } + + @Test + void isGeneratingListGetEndpointFor() { + } + + @Test + void isGeneratingPostEndpointFor() { + } + + @Test + void isGeneratingPutEndpointFor() { + } + + @Test + void isGeneratingDeleteEndpointFor() { + } + + @Test + void isGeneratingSearchEndpointFor() { + } + + @Test + void isGeneratingEndpointFor() { + } + + @Test + void isGeneratingEndpointNameWithIdFor() { + } + + @Test + void isGeneratingNewRequestFor() { + } + + @Test + void getNewRequestNameFor() { + } + + @Test + void isGeneratingListResponseFor() { + } + + @Test + void getSingleResponseNameFor() { + } + + @Test + void getListResponseNameFor() { + } + + @Test + void isGeneratingSearchRequestFor() { + } + + @Test + void getSearchRequestNameFor() { + } + + @Test + void getPluralFor() { + } + + @Test + void getSingularForProperty() { + } + + @Test + void isSeparatingByModule() { + } + + @Test + void getSingleGet() { + } + + @Test + void getListGet() { + } + + @Test + void getPost() { + } + + @Test + void getPut() { + } + + @Test + void getDelete() { + } + + @Test + void getSearch() { + } + + @Test + void getIds() { + } + + @Test + void isCreatingNewRequest() { + } + + @Test + void getCreatingNewRequestFor() { + } + + @Test + void getNewRequestNameFormat() { + } + + @Test + void getSingleResponseNameFormat() { + } + + @Test + void getListResponseNameFormat() { + } + + @Test + void getSearchRequestNameFormat() { + } + + @Test + void builder() { + } + + @Test + void toBuilder() { + } + private void checkOptions(OpenAPIGeneratorOptions options) { assertNotNull(options); - assertTrue(options.isGeneratingEndpoint()); - + assertNotNull(options.getIds()); assertNotNull(options.getSingleGet()); - assertTrue(options.getSingleGet().isGenerating()); - assertNotNull(options.getListGet()); - assertTrue(options.getListGet().isGenerating()); - assertNotNull(options.getPost()); - assertTrue(options.getPost().isGenerating()); - assertNotNull(options.getPut()); - assertTrue(options.getPut().isGenerating()); - assertNotNull(options.getDelete()); - assertFalse(options.getDelete().isGenerating()); - } + assertFalse(options.isSeparatingByModule()) ; + + assertTrue(options.isGeneratingEndpoint()) ; + assertTrue(options.isGeneratingEndpointFor("Trial")); + assertFalse(options.isGeneratingEndpointFor("AlleleMatrix")); + + assertTrue(options.isGeneratingEndpointWithId()) ; + assertTrue(options.isGeneratingEndpointNameWithIdFor("Trial")); + assertFalse(options.isGeneratingEndpointNameWithIdFor("AlleleMatrix")); + + assertTrue(options.isGeneratingNewRequestFor("Trial")); + assertFalse(options.isGeneratingNewRequestFor("BreedingMethod")); + + assertTrue(options.isGeneratingEndpointNameWithIdFor("Trial")); + assertFalse(options.isGeneratingEndpointNameWithIdFor("AlleleMatrix")); + + assertEquals("TrialNewRequest", options.getNewRequestNameFor("Trial")); + assertEquals("TrialSingleResponse", options.getSingleResponseNameFor("Trial")); + assertEquals("TrialListResponse", options.getListResponseNameFor("Trial")); + assertEquals("TrialSearchRequest", options.getSearchRequestNameFor("Trial")); + + assertEquals("Trials", options.getPluralFor("Trial")); + assertEquals("Studies", options.getPluralFor("Study")); + + assertEquals("trial", options.getSingularForProperty("trials")); + assertEquals("study", options.getSingularForProperty("studies")); + assertEquals("trialDbId", options.getSingularForProperty("trialDbIds")); + assertEquals("studyDbId", options.getSingularForProperty("studyDbIds")); + } } \ No newline at end of file diff --git a/java/core/src/test/java/org/brapi/schematools/core/utils/StringUtilsTest.java b/java/core/src/test/java/org/brapi/schematools/core/utils/StringUtilsTest.java index 2a058c5..ed5c500 100644 --- a/java/core/src/test/java/org/brapi/schematools/core/utils/StringUtilsTest.java +++ b/java/core/src/test/java/org/brapi/schematools/core/utils/StringUtilsTest.java @@ -2,14 +2,13 @@ import org.junit.jupiter.api.Test; -import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertEquals; class StringUtilsTest { @Test void toSingular() { assertEquals("DataMatrix", StringUtils.toSingular("DataMatrices")) ; - assertEquals("Analysis", StringUtils.toSingular("Analysis")) ; } @Test diff --git a/java/core/src/test/resources/BrAPI-Schema/BrAPI-Common/GeoJSONGeometry.json b/java/core/src/test/resources/BrAPI-Schema/BrAPI-Common/GeoJSONGeometry.json index dbd679f..f948029 100644 --- a/java/core/src/test/resources/BrAPI-Schema/BrAPI-Common/GeoJSONGeometry.json +++ b/java/core/src/test/resources/BrAPI-Schema/BrAPI-Common/GeoJSONGeometry.json @@ -4,6 +4,7 @@ "oneOf": [ { "description": "Copied from RFC 7946 Section 3.1.1\n\nA position is an array of numbers. There MUST be two or more elements. The first two elements are longitude and latitude, or\neasting and northing, precisely in that order and using decimal numbers. Altitude or elevation MAY be included as an optional third element.", + "title": "GeoJSONPoint", "properties": { "coordinates": { "description": "A single position", @@ -27,6 +28,7 @@ }, { "description": "An array of Linear Rings. Each Linear Ring is an array of Points. \n\nA Point is an array of numbers. There MUST be two or more elements. The first two elements are longitude and latitude, or\neasting and northing, precisely in that order and using decimal numbers. Altitude or elevation MAY be included as an optional third element.", + "title": "GeoJSONPolygon", "properties": { "coordinates": { "description": "An array of linear rings", diff --git a/java/core/src/test/resources/BrAPI-Schema/BrAPI-Common/TraitDataType.json b/java/core/src/test/resources/BrAPI-Schema/BrAPI-Common/TraitDataType.json new file mode 100644 index 0000000..04f2998 --- /dev/null +++ b/java/core/src/test/resources/BrAPI-Schema/BrAPI-Common/TraitDataType.json @@ -0,0 +1,20 @@ +{ + "$defs": { + "TraitDataType": { + "description": "

Class of the scale, entries can be

\n

\"Code\" - This scale class is exceptionally used to express complex traits. Code is a nominal scale that combines the expressions of the different traits composing the complex trait. For example a severity trait might be expressed by a 2 digit and 2 character code. The first 2 digits are the percentage of the plant covered by a fungus and the 2 characters refer to the delay in development, e.g. \"75VD\" means \"75 %\" of the plant is infected and the plant is very delayed.

\n

\"Date\" - The date class is for events expressed in a time format, See ISO 8601

\n

\"Duration\" - The Duration class is for time elapsed between two events expressed in a time format, e.g. days, hours, months

\n

\"Nominal\" - Categorical scale that can take one of a limited and fixed number of categories. There is no intrinsic ordering to the categories

\n

\"Numerical\" - Numerical scales express the trait with real numbers. The numerical scale defines the unit e.g. centimeter, ton per hectare, branches

\n

\"Ordinal\" - Ordinal scales are scales composed of ordered categories

\n

\"Text\" - A free text is used to express the trait.

", + "enum": [ + "Code", + "Date", + "Duration", + "Nominal", + "Numerical", + "Ordinal", + "Text" + ], + "type": "string", + "example": "Numerical" + } + }, + "$id": "https://brapi.org/Specification/BrAPI-Schema/Components/Common/AdditionalInfo.json", + "$schema": "http://json-schema.org/draft/2020-12/schema" +} \ No newline at end of file diff --git a/java/core/src/test/resources/BrAPI-Schema/BrAPI-Core/Location.json b/java/core/src/test/resources/BrAPI-Schema/BrAPI-Core/Location.json index 12b5f0f..1f0af58 100644 --- a/java/core/src/test/resources/BrAPI-Schema/BrAPI-Core/Location.json +++ b/java/core/src/test/resources/BrAPI-Schema/BrAPI-Core/Location.json @@ -198,7 +198,7 @@ "title": "Location", "type": "object", "brapi-metadata": { - "primaryModel": false + "primaryModel": true } } }, diff --git a/java/core/src/test/resources/BrAPI-Schema/BrAPI-Core/Person.json b/java/core/src/test/resources/BrAPI-Schema/BrAPI-Core/Person.json index c7d8e34..75fb693 100644 --- a/java/core/src/test/resources/BrAPI-Schema/BrAPI-Core/Person.json +++ b/java/core/src/test/resources/BrAPI-Schema/BrAPI-Core/Person.json @@ -112,7 +112,7 @@ "title": "Person", "type": "object", "brapi-metadata": { - "primaryModel": false + "primaryModel": true } } }, diff --git a/java/core/src/test/resources/BrAPI-Schema/BrAPI-Core/Program.json b/java/core/src/test/resources/BrAPI-Schema/BrAPI-Core/Program.json index cd4a857..dcfdcee 100644 --- a/java/core/src/test/resources/BrAPI-Schema/BrAPI-Core/Program.json +++ b/java/core/src/test/resources/BrAPI-Schema/BrAPI-Core/Program.json @@ -171,7 +171,7 @@ "title": "Program", "type": "object", "brapi-metadata": { - "primaryModel": false + "primaryModel": true } } }, diff --git a/java/core/src/test/resources/BrAPI-Schema/BrAPI-Core/Season.json b/java/core/src/test/resources/BrAPI-Schema/BrAPI-Core/Season.json index fff8df0..6b2a765 100644 --- a/java/core/src/test/resources/BrAPI-Schema/BrAPI-Core/Season.json +++ b/java/core/src/test/resources/BrAPI-Schema/BrAPI-Core/Season.json @@ -27,7 +27,7 @@ "title": "Season", "type": "object", "brapi-metadata": { - "primaryModel": false + "primaryModel": true } } }, diff --git a/java/core/src/test/resources/BrAPI-Schema/BrAPI-Core/Study.json b/java/core/src/test/resources/BrAPI-Schema/BrAPI-Core/Study.json index 8f060ca..450c55f 100644 --- a/java/core/src/test/resources/BrAPI-Schema/BrAPI-Core/Study.json +++ b/java/core/src/test/resources/BrAPI-Schema/BrAPI-Core/Study.json @@ -425,7 +425,7 @@ "title": "Study", "type": "object", "brapi-metadata": { - "primaryModel": false + "primaryModel": true } } }, diff --git a/java/core/src/test/resources/BrAPI-Schema/BrAPI-Core/Trial.json b/java/core/src/test/resources/BrAPI-Schema/BrAPI-Core/Trial.json index 863a68c..5d46c0b 100644 --- a/java/core/src/test/resources/BrAPI-Schema/BrAPI-Core/Trial.json +++ b/java/core/src/test/resources/BrAPI-Schema/BrAPI-Core/Trial.json @@ -220,7 +220,7 @@ "title": "Trial", "type": "object", "brapi-metadata": { - "primaryModel": false + "primaryModel": true } } }, diff --git a/java/core/src/test/resources/BrAPI-Schema/BrAPI-Genotyping/AlleleMatrix.json b/java/core/src/test/resources/BrAPI-Schema/BrAPI-Genotyping/AlleleMatrix.json index 4cc6e67..c047122 100644 --- a/java/core/src/test/resources/BrAPI-Schema/BrAPI-Genotyping/AlleleMatrix.json +++ b/java/core/src/test/resources/BrAPI-Schema/BrAPI-Genotyping/AlleleMatrix.json @@ -15,6 +15,7 @@ "description": "The 'dataMatrices' are an array of matrix objects that hold the allele data and associated metadata. Each matrix should be the same size and orientation, aligned with the \"callSetDbIds\" as columns and the \"variantDbIds\" as rows.", "items": { "description": "This is a single data matrix. It could be the allele matrix or an additional layer of metadata associated with each genotype value.", + "title": "DataMatrix", "properties": { "dataMatrix": { "description": "The two dimensional array of data, providing the allele matrix or an additional layer of metadata associated with each genotype value. Each matrix should be the same size and orientation, aligned with the \"callSetDbIds\" as columns and the \"variantDbIds\" as rows.", @@ -174,7 +175,7 @@ "title": "AlleleMatrix", "type": "object", "brapi-metadata": { - "primaryModel": false + "primaryModel": true } } }, diff --git a/java/core/src/test/resources/BrAPI-Schema/BrAPI-Genotyping/Call.json b/java/core/src/test/resources/BrAPI-Schema/BrAPI-Genotyping/Call.json index 5588975..3d9ab6b 100644 --- a/java/core/src/test/resources/BrAPI-Schema/BrAPI-Genotyping/Call.json +++ b/java/core/src/test/resources/BrAPI-Schema/BrAPI-Genotyping/Call.json @@ -94,7 +94,7 @@ "title": "Call", "type": "object", "brapi-metadata": { - "primaryModel": false + "primaryModel": true } } }, diff --git a/java/core/src/test/resources/BrAPI-Schema/BrAPI-Genotyping/CallSet.json b/java/core/src/test/resources/BrAPI-Schema/BrAPI-Genotyping/CallSet.json index 8b5561a..4a36036 100644 --- a/java/core/src/test/resources/BrAPI-Schema/BrAPI-Genotyping/CallSet.json +++ b/java/core/src/test/resources/BrAPI-Schema/BrAPI-Genotyping/CallSet.json @@ -100,7 +100,7 @@ "title": "CallSet", "type": "object", "brapi-metadata": { - "primaryModel": false + "primaryModel": true } } }, diff --git a/java/core/src/test/resources/BrAPI-Schema/BrAPI-Genotyping/GenomeMap.json b/java/core/src/test/resources/BrAPI-Schema/BrAPI-Genotyping/GenomeMap.json index d1031a6..c21870b 100644 --- a/java/core/src/test/resources/BrAPI-Schema/BrAPI-Genotyping/GenomeMap.json +++ b/java/core/src/test/resources/BrAPI-Schema/BrAPI-Genotyping/GenomeMap.json @@ -109,7 +109,7 @@ "title": "GenomeMap", "type": "object", "brapi-metadata": { - "primaryModel": false + "primaryModel": true } } }, diff --git a/java/core/src/test/resources/BrAPI-Schema/BrAPI-Genotyping/MarkerPosition.json b/java/core/src/test/resources/BrAPI-Schema/BrAPI-Genotyping/MarkerPosition.json index 7f5814e..f999916 100644 --- a/java/core/src/test/resources/BrAPI-Schema/BrAPI-Genotyping/MarkerPosition.json +++ b/java/core/src/test/resources/BrAPI-Schema/BrAPI-Genotyping/MarkerPosition.json @@ -36,7 +36,7 @@ "title": "MarkerPosition", "type": "object", "brapi-metadata": { - "primaryModel": false + "primaryModel": true } } }, diff --git a/java/core/src/test/resources/BrAPI-Schema/BrAPI-Genotyping/Plate.json b/java/core/src/test/resources/BrAPI-Schema/BrAPI-Genotyping/Plate.json index 0ef665f..f158745 100644 --- a/java/core/src/test/resources/BrAPI-Schema/BrAPI-Genotyping/Plate.json +++ b/java/core/src/test/resources/BrAPI-Schema/BrAPI-Genotyping/Plate.json @@ -24,6 +24,10 @@ "string" ] }, + "plateDbId": { + "description": "The ID which uniquely identifies a `Plate`", + "type": "string" + }, "plateFormat": { "description": "Enum for plate formats, usually \"PLATE_96\" for a 96 well plate or \"TUBES\" for plateless format", "enum": [ @@ -93,7 +97,7 @@ "title": "Plate", "type": "object", "brapi-metadata": { - "primaryModel": false + "primaryModel": true } } }, diff --git a/java/core/src/test/resources/BrAPI-Schema/BrAPI-Genotyping/Reference.json b/java/core/src/test/resources/BrAPI-Schema/BrAPI-Genotyping/Reference.json index cd0c118..7c0aa84 100644 --- a/java/core/src/test/resources/BrAPI-Schema/BrAPI-Genotyping/Reference.json +++ b/java/core/src/test/resources/BrAPI-Schema/BrAPI-Genotyping/Reference.json @@ -111,6 +111,7 @@ }, "species": { "description": "An ontology term describing an attribute.", + "title": "OntologyTerm", "properties": { "term": { "description": "Ontology term - the label of the ontology term the termId is pointing to.", @@ -154,7 +155,7 @@ "title": "Reference", "type": "object", "brapi-metadata": { - "primaryModel": false + "primaryModel": true } } }, diff --git a/java/core/src/test/resources/BrAPI-Schema/BrAPI-Genotyping/ReferenceSet.json b/java/core/src/test/resources/BrAPI-Schema/BrAPI-Genotyping/ReferenceSet.json index 6e417e8..39db4ec 100644 --- a/java/core/src/test/resources/BrAPI-Schema/BrAPI-Genotyping/ReferenceSet.json +++ b/java/core/src/test/resources/BrAPI-Schema/BrAPI-Genotyping/ReferenceSet.json @@ -176,7 +176,7 @@ "title": "ReferenceSet", "type": "object", "brapi-metadata": { - "primaryModel": false + "primaryModel": true } } }, diff --git a/java/core/src/test/resources/BrAPI-Schema/BrAPI-Genotyping/Sample.json b/java/core/src/test/resources/BrAPI-Schema/BrAPI-Genotyping/Sample.json index c5fef1d..62b9b7c 100644 --- a/java/core/src/test/resources/BrAPI-Schema/BrAPI-Genotyping/Sample.json +++ b/java/core/src/test/resources/BrAPI-Schema/BrAPI-Genotyping/Sample.json @@ -85,6 +85,13 @@ "string" ] }, + "sampleDbId": { + "description": "The ID which uniquely identifies a `Sample`\n
MIAPPE V1.1 (DM-76) Sample ID - Unique identifier for the sample.", + "type": [ + "null", + "string" + ] + }, "sampleGroupId": { "description": "The ID which uniquely identifies a group of `Samples`", "type": [ @@ -158,7 +165,7 @@ "title": "Sample", "type": "object", "brapi-metadata": { - "primaryModel": false + "primaryModel": true } } }, diff --git a/java/core/src/test/resources/BrAPI-Schema/BrAPI-Genotyping/Variant.json b/java/core/src/test/resources/BrAPI-Schema/BrAPI-Genotyping/Variant.json index 862d1c3..52bcbfc 100644 --- a/java/core/src/test/resources/BrAPI-Schema/BrAPI-Genotyping/Variant.json +++ b/java/core/src/test/resources/BrAPI-Schema/BrAPI-Genotyping/Variant.json @@ -203,7 +203,7 @@ "title": "Variant", "type": "object", "brapi-metadata": { - "primaryModel": false + "primaryModel": true } } }, diff --git a/java/core/src/test/resources/BrAPI-Schema/BrAPI-Genotyping/VariantSet.json b/java/core/src/test/resources/BrAPI-Schema/BrAPI-Genotyping/VariantSet.json index 356f780..e8ac10a 100644 --- a/java/core/src/test/resources/BrAPI-Schema/BrAPI-Genotyping/VariantSet.json +++ b/java/core/src/test/resources/BrAPI-Schema/BrAPI-Genotyping/VariantSet.json @@ -52,6 +52,7 @@ "description": "Set of Analysis descriptors for this VariantSet", "items": { "description": "An analysis contains an interpretation of one or several experiments. (e.g. SNVs, copy number variations, methylation status) together with information about the methodology used.", + "title": "Analysis", "properties": { "analysisDbId": { "description": "Unique identifier for this analysis description", @@ -304,7 +305,7 @@ "title": "VariantSet", "type": "object", "brapi-metadata": { - "primaryModel": false + "primaryModel": true } } }, diff --git a/java/core/src/test/resources/BrAPI-Schema/BrAPI-Germplasm/BreedingMethod.json b/java/core/src/test/resources/BrAPI-Schema/BrAPI-Germplasm/BreedingMethod.json index 882e5c6..b87ed13 100644 --- a/java/core/src/test/resources/BrAPI-Schema/BrAPI-Germplasm/BreedingMethod.json +++ b/java/core/src/test/resources/BrAPI-Schema/BrAPI-Germplasm/BreedingMethod.json @@ -65,7 +65,7 @@ "title": "Breeding Method", "type": "object", "brapi-metadata": { - "primaryModel": false + "primaryModel": true } } }, diff --git a/java/core/src/test/resources/BrAPI-Schema/BrAPI-Germplasm/Cross.json b/java/core/src/test/resources/BrAPI-Schema/BrAPI-Germplasm/Cross.json index cda37bf..7d49eba 100644 --- a/java/core/src/test/resources/BrAPI-Schema/BrAPI-Germplasm/Cross.json +++ b/java/core/src/test/resources/BrAPI-Schema/BrAPI-Germplasm/Cross.json @@ -147,7 +147,7 @@ "title": "Cross", "type": "object", "brapi-metadata": { - "primaryModel": false + "primaryModel": true } } }, diff --git a/java/core/src/test/resources/BrAPI-Schema/BrAPI-Germplasm/CrossingProject.json b/java/core/src/test/resources/BrAPI-Schema/BrAPI-Germplasm/CrossingProject.json index 7b676e7..c813212 100644 --- a/java/core/src/test/resources/BrAPI-Schema/BrAPI-Germplasm/CrossingProject.json +++ b/java/core/src/test/resources/BrAPI-Schema/BrAPI-Germplasm/CrossingProject.json @@ -105,7 +105,7 @@ "title": "CrossingProject", "type": "object", "brapi-metadata": { - "primaryModel": false + "primaryModel": true } } }, diff --git a/java/core/src/test/resources/BrAPI-Schema/BrAPI-Germplasm/Germplasm.json b/java/core/src/test/resources/BrAPI-Schema/BrAPI-Germplasm/Germplasm.json index 80a9986..4fa02b2 100644 --- a/java/core/src/test/resources/BrAPI-Schema/BrAPI-Germplasm/Germplasm.json +++ b/java/core/src/test/resources/BrAPI-Schema/BrAPI-Germplasm/Germplasm.json @@ -464,7 +464,7 @@ "title": "Germplasm", "type": "object", "brapi-metadata": { - "primaryModel": false + "primaryModel": true } } }, diff --git a/java/core/src/test/resources/BrAPI-Schema/BrAPI-Germplasm/GermplasmAttribute.json b/java/core/src/test/resources/BrAPI-Schema/BrAPI-Germplasm/GermplasmAttribute.json index 80d8946..7007168 100644 --- a/java/core/src/test/resources/BrAPI-Schema/BrAPI-Germplasm/GermplasmAttribute.json +++ b/java/core/src/test/resources/BrAPI-Schema/BrAPI-Germplasm/GermplasmAttribute.json @@ -175,7 +175,7 @@ "title": "GermplasmAttribute", "type": "object", "brapi-metadata": { - "primaryModel": false + "primaryModel": true } } }, diff --git a/java/core/src/test/resources/BrAPI-Schema/BrAPI-Germplasm/GermplasmAttributeValue.json b/java/core/src/test/resources/BrAPI-Schema/BrAPI-Germplasm/GermplasmAttributeValue.json index d222fa1..8fb064c 100644 --- a/java/core/src/test/resources/BrAPI-Schema/BrAPI-Germplasm/GermplasmAttributeValue.json +++ b/java/core/src/test/resources/BrAPI-Schema/BrAPI-Germplasm/GermplasmAttributeValue.json @@ -56,7 +56,7 @@ "title": "GermplasmAttributeValue", "type": "object", "brapi-metadata": { - "primaryModel": false + "primaryModel": true } } }, diff --git a/java/core/src/test/resources/BrAPI-Schema/BrAPI-Germplasm/PedigreeNode.json b/java/core/src/test/resources/BrAPI-Schema/BrAPI-Germplasm/PedigreeNode.json index 52dff69..3fbcad8 100644 --- a/java/core/src/test/resources/BrAPI-Schema/BrAPI-Germplasm/PedigreeNode.json +++ b/java/core/src/test/resources/BrAPI-Schema/BrAPI-Germplasm/PedigreeNode.json @@ -66,6 +66,7 @@ "parents": { "description": "A list of parent germplasm references in the pedigree tree for this germplasm. These represent edges in the tree, connecting to other nodes.\n
Typically, this array should only have one parent (clonal or self) or two parents (cross). In some special cases, there may be more parents, usually when the exact parent is not known. \n
If the parameter 'includeParents' is set to false, then this array should be empty, null, or not present in the response.", "items": { + "title": "GermplasmParent", "properties": { "parentGermplasm": { "$ref": "Germplasm.json#/$defs/Germplasm", @@ -106,6 +107,7 @@ "progeny": { "description": "A list of germplasm references that are direct children of this germplasm. These represent edges in the tree, connecting to other nodes.\n
The given germplasm could have a large number of progeny, across a number of different breeding methods. The 'parentType' shows \n the type of parent this germplasm is to each of the child germplasm references.\n
If the parameter 'includeProgeny' is set to false, then this array should be empty, null, or not present in the response.", "items": { + "title": "GermplasmChild", "properties": { "progenyGermplasm": { "$ref": "Germplasm.json#/$defs/Germplasm", @@ -139,18 +141,10 @@ "siblings": { "description": "A list of sibling germplasm references in the pedigree tree for this germplasm. These represent edges in the tree, connecting to other nodes.\n
Siblings share at least one parent with the given germplasm. \n
If the parameter 'includeSiblings' is set to false, then this array should be empty, null, or not present in the response.", "items": { - "properties": { - "siblingGermplasm": { - "$ref": "Germplasm.json#/$defs/Germplasm", - "description": "The ID which uniquely identifies a parent germplasm", - "referencedAttribute": "siblingPedigreeNodes", - "relationshipType": "many-to-one" - } - }, - "required": [ - "germplasmDbId" - ], - "type": "object" + "$ref": "Germplasm.json#/$defs/Germplasm", + "description": "The ID which uniquely identifies a parent germplasm", + "referencedAttribute": "siblingPedigreeNodes", + "relationshipType": "many-to-one" }, "type": [ "null", @@ -165,7 +159,7 @@ "title": "PedigreeNode", "type": "object", "brapi-metadata": { - "primaryModel": false + "primaryModel": true } } }, diff --git a/java/core/src/test/resources/BrAPI-Schema/BrAPI-Germplasm/PlannedCross.json b/java/core/src/test/resources/BrAPI-Schema/BrAPI-Germplasm/PlannedCross.json index 7544044..4103025 100644 --- a/java/core/src/test/resources/BrAPI-Schema/BrAPI-Germplasm/PlannedCross.json +++ b/java/core/src/test/resources/BrAPI-Schema/BrAPI-Germplasm/PlannedCross.json @@ -93,7 +93,7 @@ "title": "PlannedCross", "type": "object", "brapi-metadata": { - "primaryModel": false + "primaryModel": true } } }, diff --git a/java/core/src/test/resources/BrAPI-Schema/BrAPI-Germplasm/SeedLot.json b/java/core/src/test/resources/BrAPI-Schema/BrAPI-Germplasm/SeedLot.json index b30d94d..8d28d05 100644 --- a/java/core/src/test/resources/BrAPI-Schema/BrAPI-Germplasm/SeedLot.json +++ b/java/core/src/test/resources/BrAPI-Schema/BrAPI-Germplasm/SeedLot.json @@ -185,7 +185,7 @@ "title": "SeedLot", "type": "object", "brapi-metadata": { - "primaryModel": false + "primaryModel": true } } }, diff --git a/java/core/src/test/resources/BrAPI-Schema/BrAPI-Phenotyping/Event.json b/java/core/src/test/resources/BrAPI-Schema/BrAPI-Phenotyping/Event.json index 226546a..c4c008c 100644 --- a/java/core/src/test/resources/BrAPI-Schema/BrAPI-Phenotyping/Event.json +++ b/java/core/src/test/resources/BrAPI-Schema/BrAPI-Phenotyping/Event.json @@ -154,7 +154,7 @@ "title": "Event", "type": "object", "brapi-metadata": { - "primaryModel": false + "primaryModel": true } } }, diff --git a/java/core/src/test/resources/BrAPI-Schema/BrAPI-Phenotyping/Image.json b/java/core/src/test/resources/BrAPI-Schema/BrAPI-Phenotyping/Image.json index 9e1c1b6..5a50366 100644 --- a/java/core/src/test/resources/BrAPI-Schema/BrAPI-Phenotyping/Image.json +++ b/java/core/src/test/resources/BrAPI-Schema/BrAPI-Phenotyping/Image.json @@ -147,7 +147,7 @@ "title": "Image", "type": "object", "brapi-metadata": { - "primaryModel": false + "primaryModel": true } } }, diff --git a/java/core/src/test/resources/BrAPI-Schema/BrAPI-Phenotyping/Method.json b/java/core/src/test/resources/BrAPI-Schema/BrAPI-Phenotyping/Method.json index 29700d6..a77b9f4 100644 --- a/java/core/src/test/resources/BrAPI-Schema/BrAPI-Phenotyping/Method.json +++ b/java/core/src/test/resources/BrAPI-Schema/BrAPI-Phenotyping/Method.json @@ -74,7 +74,7 @@ "title": "Method", "type": "object", "brapi-metadata": { - "primaryModel": false + "primaryModel": true } } }, diff --git a/java/core/src/test/resources/BrAPI-Schema/BrAPI-Phenotyping/Observation.json b/java/core/src/test/resources/BrAPI-Schema/BrAPI-Phenotyping/Observation.json index 593a830..8594645 100644 --- a/java/core/src/test/resources/BrAPI-Schema/BrAPI-Phenotyping/Observation.json +++ b/java/core/src/test/resources/BrAPI-Schema/BrAPI-Phenotyping/Observation.json @@ -146,7 +146,7 @@ "title": "Observation", "type": "object", "brapi-metadata": { - "primaryModel": false + "primaryModel": true } } }, diff --git a/java/core/src/test/resources/BrAPI-Schema/BrAPI-Phenotyping/ObservationUnit.json b/java/core/src/test/resources/BrAPI-Schema/BrAPI-Phenotyping/ObservationUnit.json index 6019f02..616adb8 100644 --- a/java/core/src/test/resources/BrAPI-Schema/BrAPI-Phenotyping/ObservationUnit.json +++ b/java/core/src/test/resources/BrAPI-Schema/BrAPI-Phenotyping/ObservationUnit.json @@ -92,74 +92,13 @@ ] }, "observationLevel": { - "description": "The exact level and level code of an observation unit. \n\nFor more information on Observation Levels, please review the Observation Levels documentation. \n\nMIAPPE V1.1 DM-71 Observation unit type \"Type of observation unit in textual form, usually one of the following: study, block, sub-block, plot, sub-plot, pot, plant. Use of other observation unit types is possible but not recommended. \nThe observation unit type can not be used to indicate sub-plant levels. However, observations can still be made on the sub-plant level, as long as the details are indicated in the associated observed variable (see observed variables). \nAlternatively, it is possible to use samples for more detailed tracing of sub-plant units, attaching the observations to them instead.\" ", - "properties": { - "levelCode": { - "description": "An ID code or number to represent a real thing that may or may not be an an observation unit.\n
For example, if the 'levelName' is 'plot', then the 'levelCode' would be the plot number or plot barcode. If this plot is also considered an ObservationUnit, then the appropriate observationUnitDbId should also be recorded.\n
If the 'levelName' is 'field', then the 'levelCode' might be something like '3' or 'F3' to indicate the third field at a research station. ", - "type": [ - "null", - "string" - ] - }, - "levelName": { - "description": "A name for this level \n\n**Standard Level Names: study, field, entry, rep, block, sub-block, plot, sub-plot, plant, pot, sample** \n\nFor more information on Observation Levels, please review the Observation Levels documentation. ", - "type": [ - "null", - "string" - ] - }, - "levelOrder": { - "description": "`levelOrder` defines where that level exists in the hierarchy of levels. `levelOrder`'s lower numbers \nare at the top of the hierarchy (ie field -> 1) and higher numbers are at the bottom of the hierarchy (ie plant -> 9). \n\nFor more information on Observation Levels, please review the Observation Levels documentation. ", - "type": [ - "null", - "integer" - ] - } - }, - "required": [], - "title": "ObservationUnitLevel", - "type": [ - "null", - "object" - ] + "$ref": "../BrAPI-Phenotyping/ObservationUnitLevel.json#/$defs/ObservationUnitLevel", + "description": "The exact level and level code of an observation unit. \n\nFor more information on Observation Levels, please review the Observation Levels documentation. \n\nMIAPPE V1.1 DM-71 Observation unit type \"Type of observation unit in textual form, usually one of the following: study, block, sub-block, plot, sub-plot, pot, plant. Use of other observation unit types is possible but not recommended. \nThe observation unit type can not be used to indicate sub-plant levels. However, observations can still be made on the sub-plant level, as long as the details are indicated in the associated observed variable (see observed variables). \nAlternatively, it is possible to use samples for more detailed tracing of sub-plant units, attaching the observations to them instead.\" " }, "observationLevelRelationships": { "description": "Observation levels indicate the granularity level at which the measurements are taken. `levelName` \ndefines the level, `levelOrder` defines where that level exists in the hierarchy of levels. \n`levelOrder`s lower numbers are at the top of the hierarchy (ie field > 0) and higher numbers are \nat the bottom of the hierarchy (ie plant > 6). `levelCode` is an ID code for this level tag. Identify \nthis observation unit by each level of the hierarchy where it exists. \n\nFor more information on Observation Levels, please review the Observation Levels documentation. \n\n**Standard Level Names: study, field, entry, rep, block, sub-block, plot, sub-plot, plant, pot, sample** ", "items": { - "description": "Observation levels indicate the granularity level at which the measurements are taken. `levelName` \ndefines the level, `levelOrder` defines where that level exists in the hierarchy of levels. \n`levelOrder`s lower numbers are at the top of the hierarchy (ie field > 0) and higher numbers are \nat the bottom of the hierarchy (ie plant > 6). `levelCode` is an ID code for this level tag. Identify \nthis observation unit by each level of the hierarchy where it exists. \n\nFor more information on Observation Levels, please review the Observation Levels documentation. \n\n**Standard Level Names: study, field, entry, rep, block, sub-block, plot, sub-plot, plant, pot, sample** ", - "properties": { - "levelCode": { - "description": "An ID code or number to represent a real thing that may or may not be an an observation unit.\n
For example, if the 'levelName' is 'plot', then the 'levelCode' would be the plot number or plot barcode. If this plot is also considered an ObservationUnit, then the appropriate observationUnitDbId should also be recorded.\n
If the 'levelName' is 'field', then the 'levelCode' might be something like '3' or 'F3' to indicate the third field at a research station. ", - "type": [ - "null", - "string" - ] - }, - "levelName": { - "description": "A name for this level \n\n**Standard Level Names: study, field, entry, rep, block, sub-block, plot, sub-plot, plant, pot, sample** \n\nFor more information on Observation Levels, please review the Observation Levels documentation. ", - "type": [ - "null", - "string" - ] - }, - "levelOrder": { - "description": "`levelOrder` defines where that level exists in the hierarchy of levels. `levelOrder`'s lower numbers \nare at the top of the hierarchy (ie field -> 1) and higher numbers are at the bottom of the hierarchy (ie plant -> 9). \n\nFor more information on Observation Levels, please review the Observation Levels documentation. ", - "type": [ - "null", - "integer" - ] - }, - "observationUnitDbId": { - "description": "The ID which uniquely identifies an observation unit\n
If this level has on ObservationUnit associated with it, record the observationUnitDbId here. This is intended to construct a strict hierarchy of observationUnits. \n
If there is no ObservationUnit associated with this level, this field can set to NULL or omitted from the response.", - "type": [ - "null", - "string" - ] - } - }, - "required": [], - "title": "ObservationUnitLevelRelationship", - "type": "object" + "$ref": "../BrAPI-Phenotyping/ObservationUnitLevelRelationship.json#/$defs/ObservationUnitLevelRelationship" }, "type": [ "null", @@ -335,7 +274,7 @@ "title": "ObservationUnit", "type": "object", "brapi-metadata": { - "primaryModel": false + "primaryModel": true } } }, diff --git a/java/core/src/test/resources/BrAPI-Schema/BrAPI-Phenotyping/ObservationUnitLevel.json b/java/core/src/test/resources/BrAPI-Schema/BrAPI-Phenotyping/ObservationUnitLevel.json new file mode 100644 index 0000000..2dce1bd --- /dev/null +++ b/java/core/src/test/resources/BrAPI-Schema/BrAPI-Phenotyping/ObservationUnitLevel.json @@ -0,0 +1,35 @@ +{ + "$defs": { + "ObservationUnitLevel": { + "description": "The exact level and level code of an observation unit. \n\nFor more information on Observation Levels, please review the Observation Levels documentation. \n\nMIAPPE V1.1 DM-71 Observation unit type \"Type of observation unit in textual form, usually one of the following: study, block, sub-block, plot, sub-plot, pot, plant. Use of other observation unit types is possible but not recommended. \nThe observation unit type can not be used to indicate sub-plant levels. However, observations can still be made on the sub-plant level, as long as the details are indicated in the associated observed variable (see observed variables). \nAlternatively, it is possible to use samples for more detailed tracing of sub-plant units, attaching the observations to them instead.\" ", + "properties": { + "levelCode": { + "description": "An ID code or number to represent a real thing that may or may not be an an observation unit.\n
For example, if the 'levelName' is 'plot', then the 'levelCode' would be the plot number or plot barcode. If this plot is also considered an ObservationUnit, then the appropriate observationUnitDbId should also be recorded.\n
If the 'levelName' is 'field', then the 'levelCode' might be something like '3' or 'F3' to indicate the third field at a research station. ", + "type": [ + "null", + "string" + ] + }, + "levelName": { + "description": "A name for this level \n\n**Standard Level Names: study, field, entry, rep, block, sub-block, plot, sub-plot, plant, pot, sample** \n\nFor more information on Observation Levels, please review the Observation Levels documentation. ", + "type": [ + "null", + "string" + ] + }, + "levelOrder": { + "description": "`levelOrder` defines where that level exists in the hierarchy of levels. `levelOrder`'s lower numbers \nare at the top of the hierarchy (ie field -> 1) and higher numbers are at the bottom of the hierarchy (ie plant -> 9). \n\nFor more information on Observation Levels, please review the Observation Levels documentation. ", + "type": [ + "null", + "integer" + ] + } + }, + "required": [], + "title": "ObservationUnitLevel", + "type": "object" + } + }, + "$id": "https://brapi.org/Specification/BrAPI-Schema/BrAPI-Phenotyping/ObservationUnitLevel.json", + "$schema": "http://json-schema.org/draft/2020-12/schema" +} \ No newline at end of file diff --git a/java/core/src/test/resources/BrAPI-Schema/BrAPI-Phenotyping/ObservationUnitLevelRelationship.json b/java/core/src/test/resources/BrAPI-Schema/BrAPI-Phenotyping/ObservationUnitLevelRelationship.json new file mode 100644 index 0000000..1334d05 --- /dev/null +++ b/java/core/src/test/resources/BrAPI-Schema/BrAPI-Phenotyping/ObservationUnitLevelRelationship.json @@ -0,0 +1,41 @@ +{ + "$defs": { + "ObservationUnitLevelRelationship": { + "description": "Observation levels indicate the granularity level at which the measurements are taken. `levelName` \ndefines the level, `levelOrder` defines where that level exists in the hierarchy of levels. \n`levelOrder`s lower numbers are at the top of the hierarchy (ie field > 0) and higher numbers are \nat the bottom of the hierarchy (ie plant > 6). `levelCode` is an ID code for this level tag. Identify \nthis observation unit by each level of the hierarchy where it exists. \n\nFor more information on Observation Levels, please review the Observation Levels documentation. \n\n**Standard Level Names: study, field, entry, rep, block, sub-block, plot, sub-plot, plant, pot, sample** ", + "properties": { + "levelCode": { + "description": "An ID code or number to represent a real thing that may or may not be an an observation unit.\n
For example, if the 'levelName' is 'plot', then the 'levelCode' would be the plot number or plot barcode. If this plot is also considered an ObservationUnit, then the appropriate observationUnitDbId should also be recorded.\n
If the 'levelName' is 'field', then the 'levelCode' might be something like '3' or 'F3' to indicate the third field at a research station. ", + "type": [ + "null", + "string" + ] + }, + "levelName": { + "description": "A name for this level \n\n**Standard Level Names: study, field, entry, rep, block, sub-block, plot, sub-plot, plant, pot, sample** \n\nFor more information on Observation Levels, please review the Observation Levels documentation. ", + "type": [ + "null", + "string" + ] + }, + "levelOrder": { + "description": "`levelOrder` defines where that level exists in the hierarchy of levels. `levelOrder`'s lower numbers \nare at the top of the hierarchy (ie field -> 1) and higher numbers are at the bottom of the hierarchy (ie plant -> 9). \n\nFor more information on Observation Levels, please review the Observation Levels documentation. ", + "type": [ + "null", + "integer" + ] + }, + "observationUnitDbId": { + "description": "The ID which uniquely identifies an observation unit\n
If this level has on ObservationUnit associated with it, record the observationUnitDbId here. This is intended to construct a strict hierarchy of observationUnits. \n
If there is no ObservationUnit associated with this level, this field can set to NULL or omitted from the response.", + "type": [ + "null", + "string" + ] + } + }, + "title": "ObservationUnitLevelRelationship", + "type": "object" + } + }, + "$id": "https://brapi.org/Specification/BrAPI-Schema/BrAPI-Phenotyping/ObservationUnitLevelRelationship.json", + "$schema": "http://json-schema.org/draft/2020-12/schema" +} \ No newline at end of file diff --git a/java/core/src/test/resources/BrAPI-Schema/BrAPI-Phenotyping/ObservationVariable.json b/java/core/src/test/resources/BrAPI-Schema/BrAPI-Phenotyping/ObservationVariable.json index e669213..41e3bc6 100644 --- a/java/core/src/test/resources/BrAPI-Schema/BrAPI-Phenotyping/ObservationVariable.json +++ b/java/core/src/test/resources/BrAPI-Schema/BrAPI-Phenotyping/ObservationVariable.json @@ -765,7 +765,7 @@ "title": "ObservationVariable", "type": "object", "brapi-metadata": { - "primaryModel": false + "primaryModel": true } } }, diff --git a/java/core/src/test/resources/BrAPI-Schema/BrAPI-Phenotyping/Ontology.json b/java/core/src/test/resources/BrAPI-Schema/BrAPI-Phenotyping/Ontology.json index ff59f1f..3db0da5 100644 --- a/java/core/src/test/resources/BrAPI-Schema/BrAPI-Phenotyping/Ontology.json +++ b/java/core/src/test/resources/BrAPI-Schema/BrAPI-Phenotyping/Ontology.json @@ -65,7 +65,7 @@ "title": "Ontology", "type": "object", "brapi-metadata": { - "primaryModel": false + "primaryModel": true } } }, diff --git a/java/core/src/test/resources/BrAPI-Schema/BrAPI-Phenotyping/Scale.json b/java/core/src/test/resources/BrAPI-Schema/BrAPI-Phenotyping/Scale.json index a396918..eef9e43 100644 --- a/java/core/src/test/resources/BrAPI-Schema/BrAPI-Phenotyping/Scale.json +++ b/java/core/src/test/resources/BrAPI-Schema/BrAPI-Phenotyping/Scale.json @@ -123,7 +123,7 @@ "title": "Scale", "type": "object", "brapi-metadata": { - "primaryModel": false + "primaryModel": true } } }, diff --git a/java/core/src/test/resources/BrAPI-Schema/BrAPI-Phenotyping/Trait.json b/java/core/src/test/resources/BrAPI-Schema/BrAPI-Phenotyping/Trait.json index 0643633..d800413 100644 --- a/java/core/src/test/resources/BrAPI-Schema/BrAPI-Phenotyping/Trait.json +++ b/java/core/src/test/resources/BrAPI-Schema/BrAPI-Phenotyping/Trait.json @@ -122,7 +122,7 @@ "title": "Trait", "type": "object", "brapi-metadata": { - "primaryModel": false + "primaryModel": true } } }, diff --git a/java/core/src/test/resources/BrAPI-Schema/Requests/AlleleMatrixRequest.json b/java/core/src/test/resources/BrAPI-Schema/Requests/AlleleMatrixRequest.json new file mode 100644 index 0000000..4f536c2 --- /dev/null +++ b/java/core/src/test/resources/BrAPI-Schema/Requests/AlleleMatrixRequest.json @@ -0,0 +1,191 @@ +{ + "$defs": { + "AlleleMatrixRequest": { + "type": "object", + "properties": { + "pagination": { + "title": "AlleleMatrixPagination", + "description": "Pagination for the matrix", + "type": "array", + "items": { + "type": "object", + "properties": { + "dimension": { + "description": "the dimension of the matrix being paginated", + "type": "string", + "enum": [ + "CALLSETS", + "VARIANTS" + ], + "example": "VARIANTS" + }, + "pageSize": { + "description": "the maximum number of elements per page in this dimension of the matrix", + "type": "integer", + "example": 500 + }, + "page": { + "description": "the requested page number (zero indexed)", + "type": "integer", + "example": 0 + } + } + }, + "example": [ + { + "dimension": "variants", + "pageSize": 500, + "page": 0 + }, + { + "dimension": "callsets", + "pageSize": 1000, + "page": 4 + } + ] + }, + "preview": { + "description": "Default Value = false\n
\nIf 'preview' is set to true, then the server should only return the lists of 'callSetDbIds', \n'variantDbIds', and 'variantSetDbIds'. The server should not return any matrix data. This\nis intended to be a preview and give the client a sense of how large the matrix returned will be\n
\nIf 'preview' is set to false or not set (default), then the server should return all the matrix\ndata as requested.", + "type": "boolean", + "default": false, + "example": true + }, + "dataMatrixNames": { + "description": "`dataMatrixNames` is a list of names (ie 'Genotype', 'Read Depth' etc). This list controls which data matrices are returned in the response.", + "type": "array", + "items": { + "type": "string" + }, + "example": [ + "Genotype", + "Read Depth" + ] + }, + "dataMatrixAbbreviations": { + "description": "`dataMatrixAbbreviations` is a comma seperated list of abbreviations (ie 'GT', 'RD' etc). This list controls which data matrices are returned in the response.", + "type": "array", + "items": { + "type": "string" + }, + "example": [ + "GT", + "RD" + ] + }, + "positionRanges": { + "description": "The postion range to search\n
\nUses the format \":-\" where is the chromosome name, is \nthe starting position of the range, and is the ending position of the range", + "type": "array", + "items": { + "type": "string" + }, + "example": [ + "20:1000-35000", + "20:87000-125000" + ] + }, + "germplasmNames": { + "description": "A list of human readable `Germplasm` names", + "type": "array", + "items": { + "type": "string" + }, + "example": [ + "a03202ec", + "274e4f63" + ] + }, + "germplasmPUIs": { + "description": "A list of permanent unique identifiers associated with `Germplasm`", + "type": "array", + "items": { + "type": "string" + }, + "example": [ + "a03202ec", + "274e4f63" + ] + }, + "germplasmDbIds": { + "description": "A list of IDs which uniquely identify `Germplasm` within the given database server", + "type": "array", + "items": { + "type": "string" + }, + "example": [ + "a03202ec", + "274e4f63" + ] + }, + "sampleDbIds": { + "description": "A list of IDs which uniquely identify `Samples` within the given database server", + "type": "array", + "items": { + "type": "string" + }, + "example": [ + "a03202ec", + "274e4f63" + ] + }, + "callSetDbIds": { + "description": "A list of IDs which uniquely identify `CallSets` within the given database server", + "type": "array", + "items": { + "type": "string" + }, + "example": [ + "a03202ec", + "274e4f63" + ] + }, + "variantDbIds": { + "description": "A list of IDs which uniquely identify `Variants` within the given database server", + "type": "array", + "items": { + "type": "string" + }, + "example": [ + "bba0b258", + "ff97d4f0" + ] + }, + "variantSetDbIds": { + "description": "A list of IDs which uniquely identify `VariantSets` within the given database server", + "type": "array", + "items": { + "type": "string" + }, + "example": [ + "407c0508", + "49e24dfc" + ] + }, + "expandHomozygotes": { + "description": "Should homozygotes be expanded (true) or collapsed into a single occurrence (false)", + "type": "boolean", + "example": true + }, + "sepPhased": { + "description": "The string used as a separator for phased allele calls.", + "type": "string", + "example": "|" + }, + "sepUnphased": { + "description": "The string used as a separator for unphased allele calls.", + "type": "string", + "example": "/" + }, + "unknownString": { + "description": "The string used as a representation for missing data.", + "type": "string", + "example": "." + } + }, + "brapi-metadata": { + "request": true + } + } + }, + "$id": "https://brapi.org/Specification/BrAPI-Schema/Requests/Parameters/AlleleMatrixRequest.json", + "$schema": "http://json-schema.org/draft/2020-12/schema" +} \ No newline at end of file diff --git a/java/core/src/test/resources/BrAPI-Schema/Requests/CallRequest.json b/java/core/src/test/resources/BrAPI-Schema/Requests/CallRequest.json new file mode 100644 index 0000000..aa72a1d --- /dev/null +++ b/java/core/src/test/resources/BrAPI-Schema/Requests/CallRequest.json @@ -0,0 +1,74 @@ +{ + "$defs": { + "CallRequest": { + "allOf": [ + { + "$ref": "Parameters/PagingParameters.json#/$defs/PagingParameters" + }, + { + "type": "object", + "properties": { + "callSetDbIds": { + "description": "A list of IDs which uniquely identify `CallSets` within the given database server", + "type": "array", + "items": { + "type": "string" + }, + "example": [ + "a03202ec", + "274e4f63" + ] + }, + "variantDbIds": { + "description": "A list of IDs which uniquely identify `Variant` within the given database server", + "type": "array", + "items": { + "type": "string" + }, + "example": [ + "bba0b258", + "ff97d4f0" + ] + }, + "variantSetDbIds": { + "description": "A list of IDs which uniquely identify `VariantSets` within the given database server", + "type": "array", + "items": { + "type": "string" + }, + "example": [ + "407c0508", + "49e24dfc" + ] + }, + "expandHomozygotes": { + "description": "Should homozygotes be expanded (true) or collapsed into a single occurrence (false)", + "type": "boolean", + "example": true + }, + "sepPhased": { + "description": "The string used as a separator for phased allele calls.", + "type": "string", + "example": "|" + }, + "sepUnphased": { + "description": "The string used as a separator for unphased allele calls.", + "type": "string", + "example": "/" + }, + "unknownString": { + "description": "The string used as a representation for missing data.", + "type": "string", + "example": "." + } + } + } + ], + "brapi-metadata": { + "request": true + } + } + }, + "$id": "https://brapi.org/Specification/BrAPI-Schema/Requests/CallRequest.json", + "$schema": "http://json-schema.org/draft/2020-12/schema" +} \ No newline at end of file diff --git a/java/core/src/test/resources/BrAPI-Schema/Requests/CallSetRequest.json b/java/core/src/test/resources/BrAPI-Schema/Requests/CallSetRequest.json new file mode 100644 index 0000000..f1960e9 --- /dev/null +++ b/java/core/src/test/resources/BrAPI-Schema/Requests/CallSetRequest.json @@ -0,0 +1,94 @@ +{ + "$defs": { + "CallSetRequest": { + "allOf": [ + { + "$ref": "Parameters/PagingParameters.json#/$defs/PagingParameters" + }, + { + "$ref": "Parameters/GermplasmParameters.json#/$defs/GermplasmParameters" + }, + { + "$ref": "Parameters/CommonCropNamesParameters.json#/$defs/CommonCropNamesParameters" + }, + { + "$ref": "Parameters/ProgramParameters.json#/$defs/ProgramParameters" + }, + { + "$ref": "Parameters/TrialParameters.json#/$defs/TrialParameters" + }, + { + "$ref": "Parameters/StudyParameters.json#/$defs/StudyParameters" + }, + { + "$ref": "Parameters/ExternalReferenceParameters.json#/$defs/ExternalReferenceParameters" + }, + { + "type": "object", + "properties": { + "sampleDbIds": { + "description": "A list of IDs which uniquely identify `Samples` within the given database server", + "type": "array", + "items": { + "type": "string" + }, + "example": [ + "758d3f6d", + "39c0a3f7" + ] + }, + "sampleNames": { + "description": "A list of human readable names associated with `Samples`", + "type": "array", + "items": { + "type": "string" + }, + "example": [ + "Sample_123", + "Sample_789" + ] + }, + "callSetDbIds": { + "description": "A list of IDs which uniquely identify `CallSets` within the given database server", + "type": "array", + "items": { + "type": "string" + }, + "example": [ + "6c7486b2", + "49c36a73" + ] + }, + "callSetNames": { + "description": "A list of human readable names associated with `CallSets`", + "type": "array", + "items": { + "type": "string" + }, + "example": [ + "Sample_123_DNA_Run_456", + "Sample_789_DNA_Run_101" + ] + }, + "variantSetDbIds": { + "description": "A list of IDs which uniquely identify `VariantSets` within the given database server", + "type": "array", + "items": { + "type": "string" + }, + "example": [ + "8a9a8972", + "32a2649a" + ] + } + } + } + ], + "brapi-metadata": { + "request": true + } + } + }, + "$id": "https://brapi.org/Specification/BrAPI-Schema/Requests/CallSetRequest.json", + "$schema": "http://json-schema.org/draft/2020-12/schema" +} \ No newline at end of file diff --git a/java/core/src/test/resources/BrAPI-Schema/Requests/CrossRequest.json b/java/core/src/test/resources/BrAPI-Schema/Requests/CrossRequest.json new file mode 100644 index 0000000..e1f44ce --- /dev/null +++ b/java/core/src/test/resources/BrAPI-Schema/Requests/CrossRequest.json @@ -0,0 +1,58 @@ +{ + "$defs": { + "CrossRequest": { + "allOf": [ + { + "$ref": "Parameters/PagingParameters.json#/$defs/PagingParameters" + }, + { + "$ref": "Parameters/ExternalReferenceParameters.json#/$defs/ExternalReferenceParameters" + }, + { + "$ref": "Parameters/CommonCropNamesParameters.json#/$defs/CommonCropNamesParameters" + }, + { + "$ref": "Parameters/ProgramParameters.json#/$defs/ProgramParameters" + }, + { + "type": "object", + "properties": { + "crossingProjectDbIds": { + "description": "Search for Crossing Projects with this unique id", + "type": "array", + "items": { + "type": "string" + } + }, + "crossingProjectNames": { + "description": "The human readable name for a crossing project", + "type": "array", + "items": { + "type": "string" + } + }, + "crossDbIds": { + "description": "Search for Cross with this unique id", + "type": "array", + "items": { + "type": "string" + } + }, + "crossNames": { + "description": "Search for Cross with this human readable name", + "type": "array", + "items": { + "type": "string" + } + } + } + } + ], + "brapi-metadata": { + "request": true + } + } + }, + "$id": "https://brapi.org/Specification/BrAPI-Schema/Requests/CrossRequest.json", + "$schema": "http://json-schema.org/draft/2020-12/schema" +} \ No newline at end of file diff --git a/java/core/src/test/resources/BrAPI-Schema/Requests/CrossingProjectRequest.json b/java/core/src/test/resources/BrAPI-Schema/Requests/CrossingProjectRequest.json new file mode 100644 index 0000000..04acd68 --- /dev/null +++ b/java/core/src/test/resources/BrAPI-Schema/Requests/CrossingProjectRequest.json @@ -0,0 +1,48 @@ +{ + "$defs": { + "CrossingProjectRequest": { + "allOf": [ + { + "$ref": "Parameters/PagingParameters.json#/$defs/PagingParameters" + }, + { + "$ref": "Parameters/ExternalReferenceParameters.json#/$defs/ExternalReferenceParameters" + }, + { + "$ref": "Parameters/CommonCropNamesParameters.json#/$defs/CommonCropNamesParameters" + }, + { + "$ref": "Parameters/ProgramParameters.json#/$defs/ProgramParameters" + }, + { + "type": "object", + "properties": { + "crossingProjectDbIds": { + "description": "Search for Crossing Projects with this unique id", + "type": "array", + "items": { + "type": "string" + } + }, + "crossingProjectNames": { + "description": "The human readable name for a crossing project", + "type": "array", + "items": { + "type": "string" + } + }, + "includePotentialParents": { + "description": "If the parameter 'includePotentialParents' is false, the array 'potentialParents' should be empty, null, or excluded from the response object.", + "type": "boolean" + } + } + } + ], + "brapi-metadata": { + "request": true + } + } + }, + "$id": "https://brapi.org/Specification/BrAPI-Schema/Requests/CrossingProjectRequest.json", + "$schema": "http://json-schema.org/draft/2020-12/schema" +} \ No newline at end of file diff --git a/java/core/src/test/resources/BrAPI-Schema/Requests/EventRequest.json b/java/core/src/test/resources/BrAPI-Schema/Requests/EventRequest.json new file mode 100644 index 0000000..4dc8547 --- /dev/null +++ b/java/core/src/test/resources/BrAPI-Schema/Requests/EventRequest.json @@ -0,0 +1,63 @@ +{ + "$defs": { + "EventRequest": { + "allOf": [ + { + "$ref": "Parameters/PagingParameters.json#/$defs/PagingParameters" + }, + { + "$ref": "Parameters/StudyParameters.json#/$defs/StudyParameters" + }, + { + "type": "object", + "properties": { + "observationUnitDbIds": { + "description": "The ID which uniquely identifies an observation unit.", + "items": { + "type": "string" + }, + "type": "array", + "example": [ + "3cd0ca36", + "983f3b14" + ] + }, + "eventDbIds": { + "description": "Filter based on an Event DbId.", + "type": "array", + "items": { + "type": "string" + }, + "example": [ + "bba0b258", + "ff97d4f0" + ] + }, + "eventTypes": { + "description": "Filter based on an Event Type", + "type": "array", + "items": { + "type": "string" + } + }, + "dateRangeStart": { + "description": "Filter based on an Event start date.", + "format": "date-time", + "type": "string" + }, + "dateRangeEnd": { + "description": "Filter based on an Event start date.", + "format": "date-time", + "type": "string" + } + } + } + ], + "brapi-metadata": { + "request": true + } + } + }, + "$id": "https://brapi.org/Specification/BrAPI-Schema/Requests/EventRequest.json", + "$schema": "http://json-schema.org/draft/2020-12/schema" +} \ No newline at end of file diff --git a/java/core/src/test/resources/BrAPI-Schema/Requests/GenomeMapRequest.json b/java/core/src/test/resources/BrAPI-Schema/Requests/GenomeMapRequest.json new file mode 100644 index 0000000..4ab4933 --- /dev/null +++ b/java/core/src/test/resources/BrAPI-Schema/Requests/GenomeMapRequest.json @@ -0,0 +1,61 @@ +{ + "$defs": { + "GenomeMapRequest": { + "allOf": [ + { + "$ref": "Parameters/PagingParameters.json#/$defs/PagingParameters" + }, + { + "$ref": "Parameters/CommonCropNamesParameters.json#/$defs/CommonCropNamesParameters" + }, + { + "$ref": "Parameters/ProgramParameters.json#/$defs/ProgramParameters" + }, + { + "$ref": "Parameters/TrialParameters.json#/$defs/TrialParameters" + }, + { + "$ref": "Parameters/StudyParameters.json#/$defs/StudyParameters" + }, + { + "type": "object", + "properties": { + "mapDbIds": { + "description": "The ID which uniquely identifies a `GenomeMap`", + "items": { + "type": "string" + }, + "type": "array" + }, + "mapPUI": { + "description": "The DOI or other permanent identifier for a `GenomeMap`", + "items": { + "type": "string" + }, + "type": "array" + }, + "scientificName": { + "description": "Full scientific binomial format name. This includes Genus, Species, and Sub-species", + "items": { + "type": "string" + }, + "type": "array" + }, + "types": { + "description": "The type of map, usually \"Genetic\" or \"Physical\"", + "items": { + "type": "string" + }, + "type": "array" + } + } + } + ], + "brapi-metadata": { + "request": true + } + } + }, + "$id": "https://brapi.org/Specification/BrAPI-Schema/Requests/GenomeMapRequest.json", + "$schema": "http://json-schema.org/draft/2020-12/schema" +} \ No newline at end of file diff --git a/java/core/src/test/resources/BrAPI-Schema/Requests/GermplasmAttributeRequest.json b/java/core/src/test/resources/BrAPI-Schema/Requests/GermplasmAttributeRequest.json new file mode 100644 index 0000000..9683a0a --- /dev/null +++ b/java/core/src/test/resources/BrAPI-Schema/Requests/GermplasmAttributeRequest.json @@ -0,0 +1,68 @@ +{ + "$defs": { + "GermplasmAttributeRequest": { + "allOf": [ + { + "$ref": "Parameters/VariableBaseClassParameters.json#/$defs/VariableBaseClassParameters" + }, + { + "$ref": "Parameters/GermplasmParameters.json#/$defs/GermplasmParameters" + }, + { + "type": "object", + "properties": { + "attributeDbIds": { + "description": "List of Germplasm Attribute IDs to search for", + "items": { + "type": "string" + }, + "type": "array", + "example": [ + "2ef15c9f", + "318e7f7d" + ] + }, + "attributeNames": { + "description": "List of human readable Germplasm Attribute names to search for", + "items": { + "type": "string" + }, + "type": "array", + "example": [ + "Plant Height 1", + "Root Color" + ] + }, + "attributePUIs": { + "description": "The Permanent Unique Identifier of an Attribute, usually in the form of a URI", + "items": { + "type": "string" + }, + "type": "array", + "example": [ + "http://my-traits.com/trait/CO_123:0008012", + "http://my-traits.com/trait/CO_123:0007261" + ] + }, + "attributeCategories": { + "description": "General category for the attribute. very similar to Trait class.", + "items": { + "type": "string" + }, + "type": "array", + "example": [ + "Morphological", + "Physical" + ] + } + } + } + ], + "brapi-metadata": { + "request": true + } + } + }, + "$id": "https://brapi.org/Specification/BrAPI-Schema/Requests/GermplasmAttributeRequest.json", + "$schema": "http://json-schema.org/draft/2020-12/schema" +} \ No newline at end of file diff --git a/java/core/src/test/resources/BrAPI-Schema/Requests/GermplasmAttributeValueRequest.json b/java/core/src/test/resources/BrAPI-Schema/Requests/GermplasmAttributeValueRequest.json new file mode 100644 index 0000000..f020c12 --- /dev/null +++ b/java/core/src/test/resources/BrAPI-Schema/Requests/GermplasmAttributeValueRequest.json @@ -0,0 +1,134 @@ +{ + "$defs": { + "GermplasmAttributeValueRequest": { + "allOf": [ + { + "$ref": "Parameters/PagingParameters.json#/$defs/PagingParameters" + }, + { + "$ref": "Parameters/GermplasmParameters.json#/$defs/GermplasmParameters" + }, + { + "$ref": "Parameters/CommonCropNamesParameters.json#/$defs/CommonCropNamesParameters" + }, + { + "$ref": "Parameters/ProgramParameters.json#/$defs/ProgramParameters" + }, + { + "$ref": "Parameters/ExternalReferenceParameters.json#/$defs/ExternalReferenceParameters" + }, + { + "type": "object", + "properties": { + "attributeValueDbIds": { + "description": "List of Germplasm Attribute Value IDs to search for", + "items": { + "type": "string" + }, + "type": "array", + "example": [ + "ca4636d0", + "c8a92409" + ] + }, + "attributeDbIds": { + "description": "List of Germplasm Attribute IDs to search for", + "items": { + "type": "string" + }, + "type": "array", + "example": [ + "2ef15c9f", + "318e7f7d" + ] + }, + "attributeNames": { + "description": "List of human readable Germplasm Attribute names to search for", + "items": { + "type": "string" + }, + "type": "array", + "example": [ + "Plant Height 1", + "Root Color" + ] + }, + "ontologyDbIds": { + "description": "List of ontology IDs to search for", + "items": { + "type": "string" + }, + "type": "array", + "example": [ + "f44f7b23", + "a26b576e" + ] + }, + "methodDbIds": { + "description": "List of methods to filter search results", + "items": { + "type": "string" + }, + "type": "array", + "example": [ + "07e34f83", + "d3d5517a" + ] + }, + "scaleDbIds": { + "description": "List of scales to filter search results", + "items": { + "type": "string" + }, + "type": "array", + "example": [ + "a13ecffa", + "7e1afe4f" + ] + }, + "traitDbIds": { + "description": "List of trait unique ID to filter search results", + "items": { + "type": "string" + }, + "type": "array", + "example": [ + "ef81147b", + "78d82fad" + ] + }, + "traitClasses": { + "description": "List of trait classes to filter search results", + "items": { + "type": "string" + }, + "type": "array", + "example": [ + "morphological", + "phenological", + "agronomical" + ] + }, + "dataTypes": { + "description": "List of scale data types to filter search results", + "items": { + "$ref": "../BrAPI-Common/TraitDataType.json#/$defs/TraitDataType" + }, + "type": "array", + "example": [ + "Numerical", + "Ordinal", + "Text" + ] + } + } + } + ], + "brapi-metadata": { + "request": true + } + } + }, + "$id": "https://brapi.org/Specification/BrAPI-Schema/Requests/GermplasmAttributeValueRequest.json", + "$schema": "http://json-schema.org/draft/2020-12/schema" +} \ No newline at end of file diff --git a/java/core/src/test/resources/BrAPI-Schema/Requests/GermplasmRequest.json b/java/core/src/test/resources/BrAPI-Schema/Requests/GermplasmRequest.json new file mode 100644 index 0000000..8f6e0b1 --- /dev/null +++ b/java/core/src/test/resources/BrAPI-Schema/Requests/GermplasmRequest.json @@ -0,0 +1,160 @@ +{ + "$defs": { + "GermplasmRequest": { + "allOf": [ + { + "$ref": "Parameters/PagingParameters.json#/$defs/PagingParameters" + }, + { + "$ref": "Parameters/CommonCropNamesParameters.json#/$defs/CommonCropNamesParameters" + }, + { + "$ref": "Parameters/ProgramParameters.json#/$defs/ProgramParameters" + }, + { + "$ref": "Parameters/GermplasmParameters.json#/$defs/GermplasmParameters" + }, + { + "$ref": "Parameters/TrialParameters.json#/$defs/TrialParameters" + }, + { + "$ref": "Parameters/StudyParameters.json#/$defs/StudyParameters" + }, + { + "$ref": "Parameters/ExternalReferenceParameters.json#/$defs/ExternalReferenceParameters" + }, + { + "type": "object", + "properties": { + "germplasmPUIs": { + "description": "List of Permanent Unique Identifiers to identify germplasm", + "items": { + "type": "string" + }, + "type": "array", + "example": [ + "http://pui.per/accession/A0000003", + "http://pui.per/accession/A0000477" + ] + }, + "accessionNumbers": { + "description": "A collection of unique identifiers for materials or germplasm within a genebank\n\nMCPD (v2.1) (ACCENUMB) 2. This is the unique identifier for accessions within a genebank, and is assigned when a sample is entered into the genebank collection (e.g. \"PI 113869\").", + "items": { + "type": "string" + }, + "type": "array", + "example": [ + "A0000003", + "A0000477" + ] + }, + "collections": { + "description": "A specific panel/collection/population name this germplasm belongs to.", + "items": { + "type": "string" + }, + "type": "array", + "example": [ + "RDP1", + "MDP1" + ] + }, + "familyCodes": { + "description": "A familyCode representing the family this germplasm belongs to.", + "items": { + "type": "string" + }, + "type": "array", + "example": [ + "fa000203", + "fa009965" + ] + }, + "instituteCodes": { + "description": "The code for the institute that maintains the material. \n
MCPD (v2.1) (INSTCODE) 1. FAO WIEWS code of the institute where the accession is maintained. The codes consist of the 3-letter ISO 3166 country code of the country where the institute is located plus a number (e.g. PER001). The current set of institute codes is available from http://www.fao.org/wiews. For those institutes not yet having an FAO Code, or for those with \"obsolete\" codes, see \"Common formatting rules (v)\".", + "items": { + "type": "string" + }, + "type": "array", + "example": [ + "PER001", + "NOR001" + ] + }, + "binomialNames": { + "description": "List of the full binomial name (scientific name) to identify a germplasm", + "items": { + "type": "string" + }, + "type": "array", + "example": [ + "Aspergillus fructus", + "Zea mays" + ] + }, + "genus": { + "description": "List of Genus names to identify germplasm", + "items": { + "type": "string" + }, + "type": "array", + "example": [ + "Aspergillus", + "Zea" + ] + }, + "species": { + "description": "List of Species names to identify germplasm", + "items": { + "type": "string" + }, + "type": "array", + "example": [ + "fructus", + "mays" + ] + }, + "synonyms": { + "description": "List of alternative names or IDs used to reference this germplasm", + "items": { + "type": "string" + }, + "type": "array", + "example": [ + "variety_1", + "2c38f9b6" + ] + }, + "parentDbIds": { + "description": "Search for Germplasm with these parents", + "items": { + "type": "string" + }, + "type": "array", + "example": [ + "72c1001f", + "7346c553" + ] + }, + "progenyDbIds": { + "description": "Search for Germplasm with these children", + "items": { + "type": "string" + }, + "type": "array", + "example": [ + "16e16a7e", + "ce06cf9e" + ] + } + } + } + ], + "brapi-metadata": { + "request": true + } + } + }, + "$id": "https://brapi.org/Specification/BrAPI-Schema/Requests/GermplasmRequest.json", + "$schema": "http://json-schema.org/draft/2020-12/schema" +} \ No newline at end of file diff --git a/java/core/src/test/resources/BrAPI-Schema/Requests/ImageRequest.json b/java/core/src/test/resources/BrAPI-Schema/Requests/ImageRequest.json new file mode 100644 index 0000000..3929f15 --- /dev/null +++ b/java/core/src/test/resources/BrAPI-Schema/Requests/ImageRequest.json @@ -0,0 +1,153 @@ +{ + "$defs": { + "ImageRequest": { + "allOf": [ + { + "$ref": "Parameters/PagingParameters.json#/$defs/PagingParameters" + }, + { + "$ref": "Parameters/ExternalReferenceParameters.json#/$defs/ExternalReferenceParameters" + }, + { + "$ref": "Parameters/CommonCropNamesParameters.json#/$defs/CommonCropNamesParameters" + }, + { + "$ref": "Parameters/ProgramParameters.json#/$defs/ProgramParameters" + }, + { + "type": "object", + "properties": { + "descriptiveOntologyTerms": { + "description": "A list of terms to formally describe the image to search for. Each item could be a simple Tag, an Ontology reference Id, or a full ontology URL.", + "type": "array", + "items": { + "type": "string" + }, + "example": [ + "doi:10.1002/0470841559", + "Red", + "ncbi:0300294" + ] + }, + "imageFileNames": { + "description": "Image file names to search for.", + "items": { + "type": "string" + }, + "type": "array", + "example": [ + "image_01032019.jpg", + "picture_field_1234.jpg" + ] + }, + "imageFileSizeMax": { + "description": "A maximum image file size to search for.", + "type": "integer", + "example": 20000000 + }, + "imageFileSizeMin": { + "description": "A minimum image file size to search for.", + "type": "integer", + "example": 1000 + }, + "imageHeightMax": { + "description": "A maximum image height to search for.", + "type": "integer", + "example": 1080 + }, + "imageHeightMin": { + "description": "A minimum image height to search for.", + "type": "integer", + "example": 720 + }, + "imageLocation": { + "$ref": "Schemas/GeoJSONSearchArea.json#/$defs/GeoJSONSearchArea" + }, + "imageNames": { + "description": "Human readable names to search for.", + "items": { + "type": "string" + }, + "type": "array", + "example": [ + "Image 43", + "Tractor in field" + ] + }, + "imageTimeStampRangeEnd": { + "description": "The latest timestamp to search for.", + "format": "date-time", + "type": "string" + }, + "imageTimeStampRangeStart": { + "description": "The earliest timestamp to search for.", + "format": "date-time", + "type": "string" + }, + "imageWidthMax": { + "description": "A maximum image width to search for.", + "type": "integer", + "example": 1920 + }, + "imageWidthMin": { + "description": "A minimum image width to search for.", + "type": "integer", + "example": 1280 + }, + "mimeTypes": { + "description": "A set of image file types to search for.", + "items": { + "pattern": "image/.*", + "type": "string" + }, + "type": "array", + "example": [ + "image/jpg", + "image/jpeg", + "image/gif" + ] + }, + "observationDbIds": { + "description": "A list of observation Ids this image is associated with to search for", + "items": { + "type": "string" + }, + "type": "array", + "example": [ + "47326456", + "fc9823ac" + ] + }, + "imageDbIds": { + "description": "A list of image Ids to search for", + "items": { + "type": "string" + }, + "type": "array", + "example": [ + "564b64a6", + "0d122d1d" + ] + }, + "observationUnitDbIds": { + "description": "A set of observation unit identifiers to search for.", + "items": { + "type": "string" + }, + "type": "array", + "example": [ + "f5e4b273", + "328c9424" + ] + } + } + } + ], + "brapi-metadata": { + "request": true + } + } + }, + "$id": "https://brapi.org/Specification/BrAPI-Schema/Requests/ImageRequest.json", + "$schema": "http://json-schema.org/draft/2020-12/schema" +} \ No newline at end of file diff --git a/java/core/src/test/resources/BrAPI-Schema/Requests/MarkerPositionRequest.json b/java/core/src/test/resources/BrAPI-Schema/Requests/MarkerPositionRequest.json new file mode 100644 index 0000000..eae0311 --- /dev/null +++ b/java/core/src/test/resources/BrAPI-Schema/Requests/MarkerPositionRequest.json @@ -0,0 +1,64 @@ +{ + "$defs": { + "MarkerPositionRequest": { + "allOf": [ + { + "$ref": "Parameters/PagingParameters.json#/$defs/PagingParameters" + }, + { + "type": "object", + "properties": { + "mapDbIds": { + "description": "A list of IDs which uniquely identify `GenomeMaps` within the given database server", + "type": "array", + "items": { + "type": "string" + }, + "example": [ + "7e6fa8aa", + "bedc418c" + ] + }, + "linkageGroupNames": { + "description": "A list of Uniquely Identifiable linkage group names", + "type": "array", + "items": { + "type": "string" + }, + "example": [ + "Chromosome 2", + "Chromosome 3" + ] + }, + "variantDbIds": { + "description": "A list of IDs which uniquely identify `Variants` within the given database server", + "type": "array", + "items": { + "type": "string" + }, + "example": [ + "a0caa928", + "f8894a26" + ] + }, + "minPosition": { + "description": "The minimum position of markers in a given map", + "type": "integer", + "example": 250 + }, + "maxPosition": { + "description": "The maximum position of markers in a given map", + "type": "integer", + "example": 4000 + } + } + } + ], + "brapi-metadata": { + "request": true + } + } + }, + "$id": "https://brapi.org/Specification/BrAPI-Schema/Requests/MarkerPositionRequest.json", + "$schema": "http://json-schema.org/draft/2020-12/schema" +} \ No newline at end of file diff --git a/java/core/src/test/resources/BrAPI-Schema/Requests/MethodRequest.json b/java/core/src/test/resources/BrAPI-Schema/Requests/MethodRequest.json new file mode 100644 index 0000000..57a59fd --- /dev/null +++ b/java/core/src/test/resources/BrAPI-Schema/Requests/MethodRequest.json @@ -0,0 +1,55 @@ +{ + "$defs": { + "MethodRequest": { + "allOf": [ + { + "$ref": "Parameters/OntologyParameters.json#/$defs/OntologyParameters" + }, + { + "$ref": "Parameters/PagingParameters.json#/$defs/PagingParameters" + }, + { + "$ref": "Parameters/CommonCropNamesParameters.json#/$defs/CommonCropNamesParameters" + }, + { + "$ref": "Parameters/ProgramParameters.json#/$defs/ProgramParameters" + }, + { + "$ref": "Parameters/ExternalReferenceParameters.json#/$defs/ExternalReferenceParameters" + }, + { + "type": "object", + "properties": { + "scaleDbIds": { + "description": "The unique identifier for a method.", + "items": { + "type": "string" + }, + "type": "array", + "example": [ + "3cd0ca36", + "983f3b14" + ] + }, + "observationVariableDbIds": { + "description": "The unique identifier for an observation variable.", + "items": { + "type": "string" + }, + "type": "array", + "example": [ + "3cd0ca36", + "983f3b14" + ] + } + } + } + ], + "brapi-metadata": { + "request": true + } + } + }, + "$id": "https://brapi.org/Specification/BrAPI-Schema/Requests/MethodRequest.json", + "$schema": "http://json-schema.org/draft/2020-12/schema" +} \ No newline at end of file diff --git a/java/core/src/test/resources/BrAPI-Schema/Requests/ObservationRequest.json b/java/core/src/test/resources/BrAPI-Schema/Requests/ObservationRequest.json new file mode 100644 index 0000000..14ef5ac --- /dev/null +++ b/java/core/src/test/resources/BrAPI-Schema/Requests/ObservationRequest.json @@ -0,0 +1,122 @@ +{ + "$defs": { + "ObservationRequest": { + "allOf": [ + { + "$ref": "Parameters/PagingParameters.json#/$defs/PagingParameters" + }, + { + "$ref": "Parameters/CommonCropNamesParameters.json#/$defs/CommonCropNamesParameters" + }, + { + "$ref": "Parameters/ProgramParameters.json#/$defs/ProgramParameters" + }, + { + "$ref": "Parameters/TrialParameters.json#/$defs/TrialParameters" + }, + { + "$ref": "Parameters/StudyParameters.json#/$defs/StudyParameters" + }, + { + "$ref": "Parameters/LocationParameters.json#/$defs/LocationParameters" + }, + { + "$ref": "Parameters/GermplasmParameters.json#/$defs/GermplasmParameters" + }, + { + "$ref": "Parameters/ObservationVariableParameters.json#/$defs/ObservationVariableParameters" + }, + { + "$ref": "Parameters/ExternalReferenceParameters.json#/$defs/ExternalReferenceParameters" + }, + { + "type": "object", + "properties": { + "observationDbIds": { + "description": "The unique id of an Observation", + "items": { + "type": "string" + }, + "type": "array", + "example": [ + "6a4a59d8", + "3ff067e0" + ] + }, + "observationUnitDbIds": { + "description": "The unique id of an Observation Unit", + "items": { + "type": "string" + }, + "type": "array", + "example": [ + "76f559b5", + "066bc5d3" + ] + }, + "observationLevels": { + "description": "Searches for values in ObservationUnit->observationUnitPosition->observationLevel", + "type": "array", + "items": { + "$ref": "../BrAPI-Phenotyping/ObservationUnitLevel.json#/$defs/ObservationUnitLevel" + }, + "example": [ + { + "levelName": "plot", + "levelCode": "Plot_123" + }, + { + "levelName": "plot", + "levelCode": "Plot_456" + }, + { + "levelName": "plot", + "levelCode": "Plot_789" + } + ] + }, + "observationLevelRelationships": { + "description": "Searches for values in ObservationUnit->observationUnitPosition->observationLevelRelationships", + "type": "array", + "items": { + "$ref": "../BrAPI-Phenotyping/ObservationUnitLevelRelationship.json#/$defs/ObservationUnitLevelRelationship" + }, + "example": [ + { + "levelName": "field", + "levelCode": "Field_1" + } + ] + }, + "observationTimeStampRangeEnd": { + "description": "Timestamp range end", + "format": "date-time", + "type": "string" + }, + "observationTimeStampRangeStart": { + "description": "Timestamp range start", + "format": "date-time", + "type": "string" + }, + "seasonDbIds": { + "description": "The year or Phenotyping campaign of a multi-annual study (trees, grape, ...)", + "items": { + "type": "string" + }, + "type": "array", + "example": [ + "Spring 2018", + "Season A" + ] + } + } + } + ], + "brapi-metadata": { + "request": true + } + } + }, + "$id": "https://brapi.org/Specification/BrAPI-Schema/Requests/ObservationRequest.json", + "$schema": "http://json-schema.org/draft/2020-12/schema" +} \ No newline at end of file diff --git a/java/core/src/test/resources/BrAPI-Schema/Requests/ObservationUnitRequest.json b/java/core/src/test/resources/BrAPI-Schema/Requests/ObservationUnitRequest.json new file mode 100644 index 0000000..235b18f --- /dev/null +++ b/java/core/src/test/resources/BrAPI-Schema/Requests/ObservationUnitRequest.json @@ -0,0 +1,117 @@ +{ + "$defs": { + "ObservationUnitRequest": { + "allOf": [ + { + "$ref": "Parameters/PagingParameters.json#/$defs/PagingParameters" + }, + { + "$ref": "Parameters/CommonCropNamesParameters.json#/$defs/CommonCropNamesParameters" + }, + { + "$ref": "Parameters/ProgramParameters.json#/$defs/ProgramParameters" + }, + { + "$ref": "Parameters/TrialParameters.json#/$defs/TrialParameters" + }, + { + "$ref": "Parameters/StudyParameters.json#/$defs/StudyParameters" + }, + { + "$ref": "Parameters/LocationParameters.json#/$defs/LocationParameters" + }, + { + "$ref": "Parameters/GermplasmParameters.json#/$defs/GermplasmParameters" + }, + { + "$ref": "Parameters/ObservationVariableParameters.json#/$defs/ObservationVariableParameters" + }, + { + "$ref": "Parameters/ExternalReferenceParameters.json#/$defs/ExternalReferenceParameters" + }, + { + "type": "object", + "properties": { + "observationUnitDbIds": { + "description": "The unique id of an observation unit", + "items": { + "type": "string" + }, + "type": "array", + "example": [ + "66bab7e3", + "0e5e7f99" + ] + }, + "observationUnitNames": { + "description": "The human readable identifier for an Observation Unit", + "items": { + "type": "string" + }, + "type": "array", + "example": [ + "FieldA_PlotB", + "SpecialPlantName" + ] + }, + "observationLevels": { + "description": "Searches for values in ObservationUnit->observationUnitPosition->observationLevel", + "type": "array", + "items": { + "$ref": "../BrAPI-Phenotyping/ObservationUnitLevel.json#/$defs/ObservationUnitLevel" + }, + "example": [ + { + "levelName": "plot", + "levelCode": "Plot_123" + }, + { + "levelName": "plot", + "levelCode": "Plot_456" + }, + { + "levelName": "plot", + "levelCode": "Plot_789" + } + ] + }, + "observationLevelRelationships": { + "description": "Searches for values in ObservationUnit->observationUnitPosition->observationLevelRelationships", + "type": "array", + "items": { + "$ref": "../BrAPI-Phenotyping/ObservationUnitLevelRelationship.json#/$defs/ObservationUnitLevelRelationship" + }, + "example": [ + { + "levelName": "field", + "levelCode": "Field_1" + } + ] + }, + "includeObservations": { + "description": "Use this parameter to include a list of observations embedded in each ObservationUnit object. \n\nCAUTION - Use this parameter at your own risk. It may return large, unpaginated lists of observation data. Only set this value to True if you are sure you need to.", + "type": "boolean", + "example": false + }, + "seasonDbIds": { + "description": "The year or Phenotyping campaign of a multi-annual study (trees, grape, ...)", + "items": { + "type": "string" + }, + "type": "array", + "example": [ + "Spring 2018", + "Season A" + ] + } + } + } + ], + "brapi-metadata": { + "request": true + } + } + }, + "$id": "https://brapi.org/Specification/BrAPI-Schema/Requests/ObservationRequest.json", + "$schema": "http://json-schema.org/draft/2020-12/schema" +} \ No newline at end of file diff --git a/java/core/src/test/resources/BrAPI-Schema/Requests/ObservationVariableRequest.json b/java/core/src/test/resources/BrAPI-Schema/Requests/ObservationVariableRequest.json new file mode 100644 index 0000000..3481461 --- /dev/null +++ b/java/core/src/test/resources/BrAPI-Schema/Requests/ObservationVariableRequest.json @@ -0,0 +1,19 @@ +{ + "$defs": { + "ObservationVariableRequest": { + "allOf": [ + { + "$ref": "Parameters/VariableBaseClassParameters.json#/$defs/VariableBaseClassParameters" + }, + { + "$ref": "Parameters/ObservationVariableParameters.json#/$defs/ObservationVariableParameters" + } + ], + "brapi-metadata": { + "request": true + } + } + }, + "$id": "https://brapi.org/Specification/BrAPI-Schema/Requests/ObservationVariableRequest.json", + "$schema": "http://json-schema.org/draft/2020-12/schema" +} \ No newline at end of file diff --git a/java/core/src/test/resources/BrAPI-Schema/Requests/OntologyRequest.json b/java/core/src/test/resources/BrAPI-Schema/Requests/OntologyRequest.json new file mode 100644 index 0000000..bc32fef --- /dev/null +++ b/java/core/src/test/resources/BrAPI-Schema/Requests/OntologyRequest.json @@ -0,0 +1,31 @@ +{ + "$defs": { + "OntologyRequest": { + "allOf": [ + { + "$ref": "Parameters/OntologyParameters.json#/$defs/OntologyParameters" + }, + { + "$ref": "Parameters/PagingParameters.json#/$defs/PagingParameters" + }, + { + "type": "object", + "properties": { + "ontologyNames": { + "description": "The human readable identifier for an ontology definition.", + "items": { + "type": "string" + }, + "type": "array" + } + } + } + ], + "brapi-metadata": { + "request": true + } + } + }, + "$id": "https://brapi.org/Specification/BrAPI-Schema/Requests/OntologyRequest.json", + "$schema": "http://json-schema.org/draft/2020-12/schema" +} \ No newline at end of file diff --git a/java/core/src/test/resources/BrAPI-Schema/Requests/Parameters/GermplasmParameters.json b/java/core/src/test/resources/BrAPI-Schema/Requests/Parameters/GermplasmParameters.json new file mode 100644 index 0000000..0ca886a --- /dev/null +++ b/java/core/src/test/resources/BrAPI-Schema/Requests/Parameters/GermplasmParameters.json @@ -0,0 +1,33 @@ +{ + "$defs": { + "GermplasmParameters": { + "type": "object", + "properties": { + "germplasmDbIds": { + "description": "List of IDs which uniquely identify germplasm to search for", + "items": { + "type": "string" + }, + "type": "array", + "example": [ + "e9c6edd7", + "1b1df4a6" + ] + }, + "germplasmNames": { + "description": "List of human readable names to identify germplasm to search for", + "items": { + "type": "string" + }, + "type": "array", + "example": [ + "A0000003", + "A0000477" + ] + } + } + } + }, + "$id": "https://brapi.org/Specification/BrAPI-Schema/Requests/Parameters/GermplasmParameters.json", + "$schema": "http://json-schema.org/draft/2020-12/schema" +} \ No newline at end of file diff --git a/java/core/src/test/resources/BrAPI-Schema/Requests/Parameters/ObservationVariableParameters.json b/java/core/src/test/resources/BrAPI-Schema/Requests/Parameters/ObservationVariableParameters.json new file mode 100644 index 0000000..2982f4e --- /dev/null +++ b/java/core/src/test/resources/BrAPI-Schema/Requests/Parameters/ObservationVariableParameters.json @@ -0,0 +1,44 @@ +{ + "$defs": { + "ObservationVariableParameters": { + "type": "object", + "properties": { + "observationVariableDbIds": { + "description": "The DbIds of Variables to search for", + "items": { + "type": "string" + }, + "type": "array", + "example": [ + "a646187d", + "6d23513b" + ] + }, + "observationVariableNames": { + "description": "The names of Variables to search for", + "items": { + "type": "string" + }, + "type": "array", + "example": [ + "Plant Height in meters", + "Wheat rust score 1-5" + ] + }, + "observationVariablePUIs": { + "description": "The Permanent Unique Identifier of an Observation Variable, usually in the form of a URI", + "items": { + "type": "string" + }, + "type": "array", + "example": [ + "http://my-traits.com/trait/CO_123:0008012", + "http://my-traits.com/trait/CO_123:0007261" + ] + } + } + } + }, + "$id": "https://brapi.org/Specification/BrAPI-Schema/Requests/Parameters/ObservationVariableParameters.json", + "$schema": "http://json-schema.org/draft/2020-12/schema" +} \ No newline at end of file diff --git a/java/core/src/test/resources/BrAPI-Schema/Requests/Parameters/OntologyParameters.json b/java/core/src/test/resources/BrAPI-Schema/Requests/Parameters/OntologyParameters.json new file mode 100644 index 0000000..0c2558a --- /dev/null +++ b/java/core/src/test/resources/BrAPI-Schema/Requests/Parameters/OntologyParameters.json @@ -0,0 +1,18 @@ +{ + "$defs": { + "OntologyParameters": { + "type": "object", + "properties": { + "ontologyDbIds": { + "description": "The unique identifier for an ontology definition. Use this parameter to filter results based on a specific ontology \n\n Use `GET /ontologies` to find the list of available ontologies on a server.", + "items": { + "type": "string" + }, + "type": "array" + } + } + } + }, + "$id": "https://brapi.org/Specification/BrAPI-Schema/Requests/Parameters/OntologyParameters.json", + "$schema": "http://json-schema.org/draft/2020-12/schema" +} diff --git a/java/core/src/test/resources/BrAPI-Schema/Requests/Parameters/StudyParameters.json b/java/core/src/test/resources/BrAPI-Schema/Requests/Parameters/StudyParameters.json new file mode 100644 index 0000000..c962853 --- /dev/null +++ b/java/core/src/test/resources/BrAPI-Schema/Requests/Parameters/StudyParameters.json @@ -0,0 +1,33 @@ +{ + "$defs": { + "StudyParameters": { + "type": "object", + "properties": { + "studyDbIds": { + "description": "List of study identifiers to search for", + "items": { + "type": "string" + }, + "type": "array", + "example": [ + "cf6c4bd4", + "691e69d6" + ] + }, + "studyNames": { + "description": "List of study names to filter search results", + "items": { + "type": "string" + }, + "type": "array", + "example": [ + "The First Bob Study 2017", + "Wheat Yield Trial 246" + ] + } + } + } + }, + "$id": "https://brapi.org/Specification/BrAPI-Schema/Requests/Parameters/StudyParameters.json", + "$schema": "http://json-schema.org/draft/2020-12/schema" +} \ No newline at end of file diff --git a/java/core/src/test/resources/BrAPI-Schema/Requests/Parameters/TrialParameters.json b/java/core/src/test/resources/BrAPI-Schema/Requests/Parameters/TrialParameters.json new file mode 100644 index 0000000..7e99e60 --- /dev/null +++ b/java/core/src/test/resources/BrAPI-Schema/Requests/Parameters/TrialParameters.json @@ -0,0 +1,33 @@ +{ + "$defs": { + "TrialParameters": { + "type": "object", + "properties": { + "trialDbIds": { + "description": "The ID which uniquely identifies a trial to search for", + "type": "array", + "items": { + "type": "string" + }, + "example": [ + "d2593dc2", + "9431a731" + ] + }, + "trialNames": { + "description": "The human readable name of a trial to search for", + "type": "array", + "items": { + "type": "string" + }, + "example": [ + "All Yield Trials 2016", + "Disease Resistance Study Comparison Group" + ] + } + } + } + }, + "$id": "https://brapi.org/Specification/BrAPI-Schema/Requests/Parameters/TrialParameters.json", + "$schema": "http://json-schema.org/draft/2020-12/schema" +} \ No newline at end of file diff --git a/java/core/src/test/resources/BrAPI-Schema/Requests/Parameters/VariableBaseClassParameters.json b/java/core/src/test/resources/BrAPI-Schema/Requests/Parameters/VariableBaseClassParameters.json new file mode 100644 index 0000000..637b7ed --- /dev/null +++ b/java/core/src/test/resources/BrAPI-Schema/Requests/Parameters/VariableBaseClassParameters.json @@ -0,0 +1,223 @@ +{ + "$defs": { + "VariableBaseClassParameters": { + "allOf": [ + { + "$ref": "PagingParameters.json#/$defs/PagingParameters" + }, + { + "$ref": "ExternalReferenceParameters.json#/$defs/ExternalReferenceParameters" + }, + { + "$ref": "CommonCropNamesParameters.json#/$defs/CommonCropNamesParameters" + }, + { + "$ref": "ProgramParameters.json#/$defs/ProgramParameters" + }, + { + "$ref": "TrialParameters.json#/$defs/TrialParameters" + }, + { + "$ref": "StudyParameters.json#/$defs/StudyParameters" + }, + { + "type": "object", + "properties": { + "studyDbId": { + "description": "**Deprecated in v2.1** Please use `studyDbIds`. Github issue number #483 \n
The unique ID of a studies to filter on", + "deprecated": true, + "type": "array", + "items": { + "type": "string" + }, + "example": [ + "5bcac0ae", + "7f48e22d" + ] + }, + "ontologyDbIds": { + "description": "List of ontology IDs to search for", + "items": { + "type": "string" + }, + "type": "array", + "example": [ + "f44f7b23", + "a26b576e" + ] + }, + "methodDbIds": { + "description": "List of methods to filter search results", + "items": { + "type": "string" + }, + "type": "array", + "example": [ + "07e34f83", + "d3d5517a" + ] + }, + "methodNames": { + "description": "Human readable name for the method\n
MIAPPE V1.1 (DM-88) Method Name of the method of observation", + "items": { + "type": "string" + }, + "type": "array", + "example": [ + "Measuring Tape", + "Spectrometer" + ] + }, + "methodPUIs": { + "description": "The Permanent Unique Identifier of a Method, usually in the form of a URI", + "items": { + "type": "string" + }, + "type": "array", + "example": [ + "http://my-traits.com/trait/CO_123:0000212", + "http://my-traits.com/trait/CO_123:0003557" + ] + }, + "scaleDbIds": { + "description": "The unique identifier for a Scale", + "items": { + "type": "string" + }, + "type": "array", + "example": [ + "a13ecffa", + "7e1afe4f" + ] + }, + "scaleNames": { + "description": "Name of the scale\n
MIAPPE V1.1 (DM-92) Scale Name of the scale associated with the variable", + "items": { + "type": "string" + }, + "type": "array", + "example": [ + "Meters", + "Liters" + ] + }, + "scalePUIs": { + "description": "The Permanent Unique Identifier of a Scale, usually in the form of a URI", + "items": { + "type": "string" + }, + "type": "array", + "example": [ + "http://my-traits.com/trait/CO_123:0000336", + "http://my-traits.com/trait/CO_123:0000560" + ] + }, + "dataTypes": { + "description": "List of scale data types to filter search results", + "items": { + "$ref": "../../BrAPI-Common/TraitDataType.json#/$defs/TraitDataType" + }, + "type": "array", + "example": [ + "Numerical", + "Ordinal", + "Text" + ] + }, + "traitClasses": { + "description": "List of trait classes to filter search results", + "items": { + "type": "string" + }, + "type": "array", + "example": [ + "morphological", + "phenological", + "agronomical" + ] + }, + "traitDbIds": { + "description": "The unique identifier for a Trait", + "items": { + "type": "string" + }, + "type": "array", + "example": [ + "ef81147b", + "78d82fad" + ] + }, + "traitNames": { + "description": "The human readable name of a trait\n
MIAPPE V1.1 (DM-86) Trait - Name of the (plant or environmental) trait under observation", + "items": { + "type": "string" + }, + "type": "array", + "example": [ + "Stalk Height", + "Root Color" + ] + }, + "traitPUIs": { + "description": "The Permanent Unique Identifier of a Trait, usually in the form of a URI", + "items": { + "type": "string" + }, + "type": "array", + "example": [ + "http://my-traits.com/trait/CO_123:0000456", + "http://my-traits.com/trait/CO_123:0000820" + ] + }, + "traitAttributes": { + "description": "A trait can be decomposed as \"Trait\" = \"Entity\" + \"Attribute\", the attribute is the observed feature (or characteristic) of the entity e.g., for \"grain colour\", attribute = \"colour\"", + "items": { + "type": "string" + }, + "type": "array", + "example": [ + "Height", + "Color" + ] + }, + "traitAttributePUIs": { + "description": "The Permanent Unique Identifier of a Trait Attribute, usually in the form of a URI\n
A trait can be decomposed as \"Trait\" = \"Entity\" + \"Attribute\", the attribute is the observed feature (or characteristic) of the entity e.g., for \"grain colour\", attribute = \"colour\"", + "items": { + "type": "string" + }, + "type": "array", + "example": [ + "http://my-traits.com/trait/CO_123:0008336", + "http://my-traits.com/trait/CO_123:0001092" + ] + }, + "traitEntities": { + "description": "A trait can be decomposed as \"Trait\" = \"Entity\" + \"Attribute\", the entity is the part of the plant that the trait refers to e.g., for \"grain colour\", entity = \"grain\"", + "items": { + "type": "string" + }, + "type": "array", + "example": [ + "Stalk", + "Root" + ] + }, + "traitEntityPUIs": { + "description": "The Permanent Unique Identifier of a Trait Entity, usually in the form of a URI\n
A trait can be decomposed as \"Trait\" = \"Entity\" + \"Attribute\", the entity is the part of the plant that the trait refers to e.g., for \"grain colour\", entity = \"grain\" ", + "items": { + "type": "string" + }, + "type": "array", + "example": [ + "http://my-traits.com/trait/CO_123:0004098", + "http://my-traits.com/trait/CO_123:0002366" + ] + } + } + } + ] + } + }, + "$id": "https://brapi.org/Specification/BrAPI-Schema/Requests/Parameters/VariableBaseClassParameters.json", + "$schema": "http://json-schema.org/draft/2020-12/schema" +} diff --git a/java/core/src/test/resources/BrAPI-Schema/Requests/PedigreeNodeRequest.json b/java/core/src/test/resources/BrAPI-Schema/Requests/PedigreeNodeRequest.json new file mode 100644 index 0000000..9a5e293 --- /dev/null +++ b/java/core/src/test/resources/BrAPI-Schema/Requests/PedigreeNodeRequest.json @@ -0,0 +1,171 @@ +{ + "$defs": { + "PedigreeNodeRequest": { + "allOf": [ + { + "$ref": "Parameters/PagingParameters.json#/$defs/PagingParameters" + }, + { + "$ref": "Parameters/GermplasmParameters.json#/$defs/GermplasmParameters" + }, + { + "$ref": "Parameters/CommonCropNamesParameters.json#/$defs/CommonCropNamesParameters" + }, + { + "$ref": "Parameters/ProgramParameters.json#/$defs/ProgramParameters" + }, + { + "$ref": "Parameters/GermplasmParameters.json#/$defs/GermplasmParameters" + }, + { + "$ref": "Parameters/TrialParameters.json#/$defs/TrialParameters" + }, + { + "$ref": "Parameters/StudyParameters.json#/$defs/StudyParameters" + }, + { + "$ref": "Parameters/ExternalReferenceParameters.json#/$defs/ExternalReferenceParameters" + }, + { + "type": "object", + "properties": { + "germplasmPUIs": { + "description": "List of Permanent Unique Identifiers to identify germplasm", + "items": { + "type": "string" + }, + "type": "array", + "example": [ + "http://pui.per/accession/A0000003", + "http://pui.per/accession/A0000477" + ] + }, + "accessionNumbers": { + "description": "A collection of unique identifiers for materials or germplasm within a genebank\n\nMCPD (v2.1) (ACCENUMB) 2. This is the unique identifier for accessions within a genebank, and is assigned when a sample is entered into the genebank collection (e.g. \"PI 113869\").", + "items": { + "type": "string" + }, + "type": "array", + "example": [ + "A0000003", + "A0000477" + ] + }, + "collections": { + "description": "A specific panel/collection/population name this germplasm belongs to.", + "items": { + "type": "string" + }, + "type": "array", + "example": [ + "RDP1", + "MDP1" + ] + }, + "familyCodes": { + "description": "A familyCode representing the family this germplasm belongs to.", + "items": { + "type": "string" + }, + "type": "array", + "example": [ + "f0000203", + "fa009965" + ] + }, + "instituteCodes": { + "description": "The code for the institute that maintains the material. \n
MCPD (v2.1) (INSTCODE) 1. FAO WIEWS code of the institute where the accession is maintained. The codes consist of the 3-letter ISO 3166 country code of the country where the institute is located plus a number (e.g. PER001). The current set of institute codes is available from http://www.fao.org/wiews. For those institutes not yet having an FAO Code, or for those with \"obsolete\" codes, see \"Common formatting rules (v)\".", + "items": { + "type": "string" + }, + "type": "array", + "example": [ + "PER001", + "NOR001" + ] + }, + "binomialNames": { + "description": "List of the full binomial name (scientific name) to identify a germplasm", + "items": { + "type": "string" + }, + "type": "array", + "example": [ + "Aspergillus fructus", + "Zea mays" + ] + }, + "genus": { + "description": "List of Genus names to identify germplasm", + "items": { + "type": "string" + }, + "type": "array", + "example": [ + "Aspergillus", + "Zea" + ] + }, + "species": { + "description": "List of Species names to identify germplasm", + "items": { + "type": "string" + }, + "type": "array", + "example": [ + "fructus", + "mays" + ] + }, + "synonyms": { + "description": "List of alternative names or IDs used to reference this germplasm", + "items": { + "type": "string" + }, + "type": "array", + "example": [ + "variety_1", + "2c38f9b6" + ] + }, + "includeParents": { + "description": "If this parameter is true, include the array of parents in the response", + "type": "boolean", + "example": true + }, + "includeSiblings": { + "description": "If this parameter is true, include the array of siblings in the response", + "type": "boolean", + "example": true + }, + "includeProgeny": { + "description": "If this parameter is true, include the array of progeny in the response", + "type": "boolean", + "example": true + }, + "includeFullTree": { + "description": "If this parameter is true, recursively include ALL of the nodes available in this pedigree tree", + "type": "boolean", + "example": true + }, + "pedigreeDepth": { + "description": "Recursively include this number of levels up the tree in the response (parents, grand-parents, great-grand-parents, etc)", + "type": "integer", + "example": 3 + }, + "progenyDepth": { + "description": "Recursively include this number of levels down the tree in the response (children, grand-children, great-grand-children, etc)", + "type": "integer", + "example": 3 + } + } + } + ], + "brapi-metadata": { + "request": true + } + } + }, + "$id": "https://brapi.org/Specification/BrAPI-Schema/Requests/PedigreeNodeRequest.json", + "$schema": "http://json-schema.org/draft/2020-12/schema" +} \ No newline at end of file diff --git a/java/core/src/test/resources/BrAPI-Schema/Requests/PersonRequest.json b/java/core/src/test/resources/BrAPI-Schema/Requests/PersonRequest.json new file mode 100644 index 0000000..fdc9bbf --- /dev/null +++ b/java/core/src/test/resources/BrAPI-Schema/Requests/PersonRequest.json @@ -0,0 +1,118 @@ +{ + "$defs": { + "PersonRequest": { + "allOf": [ + { + "$ref": "Parameters/PagingParameters.json#/$defs/PagingParameters" + }, + { + "$ref": "Parameters/ExternalReferenceParameters.json#/$defs/ExternalReferenceParameters" + }, + { + "$ref": "Parameters/CommonCropNamesParameters.json#/$defs/CommonCropNamesParameters" + }, + { + "$ref": "Parameters/ProgramParameters.json#/$defs/ProgramParameters" + }, + { + "type": "object", + "properties": { + "emailAddresses": { + "description": "email address for this person", + "type": "array", + "items": { + "type": "string" + }, + "example": [ + "bob@bob.com", + "rob@bob.com" + ] + }, + "firstNames": { + "description": "Persons first name", + "type": "array", + "items": { + "type": "string" + }, + "example": [ + "Bob", + "Rob" + ] + }, + "lastNames": { + "description": "Persons last name", + "type": "array", + "items": { + "type": "string" + }, + "example": [ + "Robertson", + "Smith" + ] + }, + "mailingAddresses": { + "description": "physical address of this person", + "type": "array", + "items": { + "type": "string" + }, + "example": [ + "123 Main Street", + "456 Side Street" + ] + }, + "middleNames": { + "description": "Persons middle name", + "type": "array", + "items": { + "type": "string" + }, + "example": [ + "Danger", + "Fight" + ] + }, + "personDbIds": { + "description": "Unique ID for this person", + "type": "array", + "items": { + "type": "string" + }, + "example": [ + "1e7731ab", + "bc28cff8" + ] + }, + "phoneNumbers": { + "description": "phone number of this person", + "type": "array", + "items": { + "type": "string" + }, + "example": [ + "9995555555", + "8884444444" + ] + }, + "userIDs": { + "description": "A systems user ID associated with this person. Different from personDbId because you could have a person who is not a user of the system.", + "type": "array", + "items": { + "type": "string" + }, + "example": [ + "bob", + "rob" + ] + } + } + } + ], + "brapi-metadata": { + "request": true + } + } + }, + "$id": "https://brapi.org/Specification/BrAPI-Schema/Requests/PersonRequest.json", + "$schema": "http://json-schema.org/draft/2020-12/schema" +} \ No newline at end of file diff --git a/java/core/src/test/resources/BrAPI-Schema/Requests/PlannedCrossRequest.json b/java/core/src/test/resources/BrAPI-Schema/Requests/PlannedCrossRequest.json new file mode 100644 index 0000000..33e1a7f --- /dev/null +++ b/java/core/src/test/resources/BrAPI-Schema/Requests/PlannedCrossRequest.json @@ -0,0 +1,71 @@ +{ + "$defs": { + "PlannedCrossRequest": { + "allOf": [ + { + "$ref": "Parameters/PagingParameters.json#/$defs/PagingParameters" + }, + { + "$ref": "Parameters/ExternalReferenceParameters.json#/$defs/ExternalReferenceParameters" + }, + { + "$ref": "Parameters/CommonCropNamesParameters.json#/$defs/CommonCropNamesParameters" + }, + { + "$ref": "Parameters/ProgramParameters.json#/$defs/ProgramParameters" + }, + { + "type": "object", + "properties": { + "crossingProjectDbIds": { + "description": "Search for Crossing Projects with this unique id", + "type": "array", + "items": { + "type": "string" + } + }, + "crossingProjectNames": { + "description": "The human readable name for a crossing project", + "type": "array", + "items": { + "type": "string" + } + }, + "plannedCrossDbIds": { + "description": "Search for Planned Cross with this unique id", + "type": "array", + "items": { + "type": "string" + } + }, + "plannedCrossNames": { + "description": "Search for Planned Cross with this human readable name", + "type": "array", + "items": { + "type": "string" + } + }, + "statuses": { + "description": "The status of this planned cross. Is it waiting to be performed ('TODO'), has it been completed successfully ('DONE'), or has it not been done on purpose ('SKIPPED').", + "type": "array", + "items": { + "title": "CrossStatus", + "type": "string", + "enum": [ + "TODO", + "DONE", + "SKIPPED" + ] + } + } + } + } + ], + "brapi-metadata": { + "request": true + } + } + }, + "$id": "https://brapi.org/Specification/BrAPI-Schema/Requests/PlannedCrossRequest.json", + "$schema": "http://json-schema.org/draft/2020-12/schema" +} \ No newline at end of file diff --git a/java/core/src/test/resources/BrAPI-Schema/Requests/PlateRequest.json b/java/core/src/test/resources/BrAPI-Schema/Requests/PlateRequest.json new file mode 100644 index 0000000..abb792f --- /dev/null +++ b/java/core/src/test/resources/BrAPI-Schema/Requests/PlateRequest.json @@ -0,0 +1,127 @@ +{ + "$defs": { + "PlateRequest": { + "allOf": [ + { + "$ref": "Parameters/PagingParameters.json#/$defs/PagingParameters" + }, + { + "$ref": "Parameters/GermplasmParameters.json#/$defs/GermplasmParameters" + }, + { + "$ref": "Parameters/CommonCropNamesParameters.json#/$defs/CommonCropNamesParameters" + }, + { + "$ref": "Parameters/ProgramParameters.json#/$defs/ProgramParameters" + }, + { + "$ref": "Parameters/TrialParameters.json#/$defs/TrialParameters" + }, + { + "$ref": "Parameters/StudyParameters.json#/$defs/StudyParameters" + }, + { + "$ref": "Parameters/ExternalReferenceParameters.json#/$defs/ExternalReferenceParameters" + }, + { + "type": "object", + "properties": { + "observationUnitDbIds": { + "description": "The ID which uniquely identifies an observation unit", + "items": { + "type": "string" + }, + "type": "array", + "example": [ + "3cd0ca36", + "983f3b14" + ] + }, + "plateDbIds": { + "description": "The ID which uniquely identifies a plate of samples", + "items": { + "type": "string" + }, + "type": "array", + "example": [ + "0cac98b8", + "b96125fb" + ] + }, + "plateNames": { + "description": "The human readable name of a plate of samples", + "items": { + "type": "string" + }, + "type": "array", + "example": [ + "0cac98b8", + "b96125fb" + ] + }, + "plateBarcodes": { + "description": "A unique identifier physically attached to the plate", + "items": { + "type": "string" + }, + "type": "array", + "example": [ + "11223344", + "55667788" + ] + }, + "sampleDbIds": { + "description": "The ID which uniquely identifies a sample", + "items": { + "type": "string" + }, + "type": "array", + "example": [ + "3bece2ca", + "dd286cc6" + ] + }, + "sampleNames": { + "description": "The human readable name of the sample", + "items": { + "type": "string" + }, + "type": "array", + "example": [ + "SA_111", + "SA_222" + ] + }, + "sampleGroupDbIds": { + "description": "The unique identifier for a group of related Samples", + "items": { + "type": "string" + }, + "type": "array", + "example": [ + "45e1e2d7", + "6cc6dd28" + ] + }, + "germplasmDbIds": { + "description": "The ID which uniquely identifies a germplasm", + "items": { + "type": "string" + }, + "type": "array", + "example": [ + "d745e1e2", + "6dd28d74" + ] + } + } + } + ], + "brapi-metadata": { + "request": true + } + } + }, + "$id": "https://brapi.org/Specification/BrAPI-Schema/Requests/PlateRequest.json", + "$schema": "http://json-schema.org/draft/2020-12/schema" +} \ No newline at end of file diff --git a/java/core/src/test/resources/BrAPI-Schema/Requests/ProgramRequest.json b/java/core/src/test/resources/BrAPI-Schema/Requests/ProgramRequest.json new file mode 100644 index 0000000..1c3f69a --- /dev/null +++ b/java/core/src/test/resources/BrAPI-Schema/Requests/ProgramRequest.json @@ -0,0 +1,89 @@ +{ + "$defs": { + "ProgramRequest": { + "allOf": [ + { + "$ref": "Parameters/PagingParameters.json#/$defs/PagingParameters" + }, + { + "$ref": "Parameters/ExternalReferenceParameters.json#/$defs/ExternalReferenceParameters" + }, + { + "$ref": "Parameters/CommonCropNamesParameters.json#/$defs/CommonCropNamesParameters" + }, + { + "$ref": "Parameters/ProgramParameters.json#/$defs/ProgramParameters" + }, + { + "type": "object", + "properties": { + "abbreviations": { + "description": "A list of shortened human readable names for a set of Programs", + "items": { + "type": "string" + }, + "type": "array", + "example": [ + "P1", + "P2" + ] + }, + "leadPersonDbIds": { + "description": "The person DbIds of the program leader to search for", + "items": { + "type": "string" + }, + "type": "array", + "example": [ + "d8bd96c7", + "a2b9c8e7" + ] + }, + "leadPersonNames": { + "description": "The names of the program leader to search for", + "items": { + "type": "string" + }, + "type": "array", + "example": [ + "Bob Robertson", + "Rob Robertson" + ] + }, + "objectives": { + "description": "A program objective to search for", + "items": { + "type": "string" + }, + "type": "array", + "example": [ + "Objective Code One", + "This is a longer objective search query" + ] + }, + "programTypes": { + "description": "The type of program entity this object represents\n
'STANDARD' represents a standard, permanent breeding program\n
'PROJECT' represents a short term project, usually with a set time limit based on funding ", + "items": { + "type": "string", + "enum": [ + "STANDARD", + "PROJECT" + ] + }, + "type": "array", + "example": [ + "STANDARD", + "PROJECT" + ] + } + } + } + ], + "brapi-metadata": { + "request": true + } + } + }, + "$id": "https://brapi.org/Specification/BrAPI-Schema/Requests/ProgramRequest.json", + "$schema": "http://json-schema.org/draft/2020-12/schema" +} \ No newline at end of file diff --git a/java/core/src/test/resources/BrAPI-Schema/Requests/ReferenceRequest.json b/java/core/src/test/resources/BrAPI-Schema/Requests/ReferenceRequest.json new file mode 100644 index 0000000..e9ba8d0 --- /dev/null +++ b/java/core/src/test/resources/BrAPI-Schema/Requests/ReferenceRequest.json @@ -0,0 +1,97 @@ +{ + "$defs": { + "ReferenceRequest": { + "allOf": [ + { + "$ref": "Parameters/PagingParameters.json#/$defs/PagingParameters" + }, + { + "$ref": "Parameters/GermplasmParameters.json#/$defs/GermplasmParameters" + }, + { + "$ref": "Parameters/ProgramParameters.json#/$defs/ProgramParameters" + }, + { + "$ref": "Parameters/CommonCropNamesParameters.json#/$defs/CommonCropNamesParameters" + }, + { + "$ref": "Parameters/TrialParameters.json#/$defs/TrialParameters" + }, + { + "$ref": "Parameters/StudyParameters.json#/$defs/StudyParameters" + }, + { + "$ref": "Parameters/ExternalReferenceParameters.json#/$defs/ExternalReferenceParameters" + }, + { + "type": "object", + "properties": { + "accessions": { + "type": "array", + "description": "If specified, return the references for which the `accession` matches this string (case-sensitive, exact match).", + "items": { + "type": "string" + }, + "example": [ + "A0009283", + "A0006657" + ] + }, + "md5checksums": { + "type": "array", + "description": "If specified, return the references for which the `md5checksum` matches this string (case-sensitive, exact match).", + "items": { + "type": "string" + }, + "example": [ + "c2365e900c81a89cf74d83dab60df146" + ] + }, + "referenceDbIds": { + "type": "array", + "description": "A list of IDs which uniquely identify `References` within the given database server", + "items": { + "type": "string" + }, + "example": [ + "04c83ea7", + "d0998a34" + ] + }, + "referenceSetDbIds": { + "type": "array", + "description": "A list of IDs which uniquely identify `ReferenceSets` within the given database server", + "items": { + "type": "string" + }, + "example": [ + "32a19dd7", + "2c182c18" + ] + }, + "isDerived": { + "description": "A sequence X is said to be derived from source sequence Y, if X and Y are of the same length and the per-base sequence divergence at A/C/G/T bases is sufficiently small. Two sequences derived from the same official sequence share the same coordinates and annotations, and can be replaced with the official sequence for certain use cases.", + "format": "boolean", + "type": "boolean" + }, + "minLength": { + "description": "The minimum length of this `References` sequence.", + "type": "integer", + "example": 4000 + }, + "maxLength": { + "description": "The minimum length of this `References` sequence.", + "type": "integer", + "example": 90000 + } + } + } + ], + "brapi-metadata": { + "request": true + } + } + }, + "$id": "https://brapi.org/Specification/BrAPI-Schema/Requests/ReferenceRequest.json", + "$schema": "http://json-schema.org/draft/2020-12/schema" +} \ No newline at end of file diff --git a/java/core/src/test/resources/BrAPI-Schema/Requests/ReferenceSetRequest.json b/java/core/src/test/resources/BrAPI-Schema/Requests/ReferenceSetRequest.json new file mode 100644 index 0000000..078d7cc --- /dev/null +++ b/java/core/src/test/resources/BrAPI-Schema/Requests/ReferenceSetRequest.json @@ -0,0 +1,82 @@ +{ + "$defs": { + "ReferenceSetRequest": { + "allOf": [ + { + "$ref": "Parameters/PagingParameters.json#/$defs/PagingParameters" + }, + { + "$ref": "Parameters/CommonCropNamesParameters.json#/$defs/CommonCropNamesParameters" + }, + { + "$ref": "Parameters/ProgramParameters.json#/$defs/ProgramParameters" + }, + { + "$ref": "Parameters/GermplasmParameters.json#/$defs/GermplasmParameters" + }, + { + "$ref": "Parameters/TrialParameters.json#/$defs/TrialParameters" + }, + { + "$ref": "Parameters/StudyParameters.json#/$defs/StudyParameters" + }, + { + "$ref": "Parameters/ExternalReferenceParameters.json#/$defs/ExternalReferenceParameters" + }, + { + "type": "object", + "properties": { + "accessions": { + "type": "array", + "description": "If set, return the reference sets for which the `accession` matches this string (case-sensitive, exact match).", + "items": { + "type": "string" + }, + "example": [ + "A0009283", + "A0006657" + ] + }, + "assemblyPUIs": { + "type": "array", + "description": "If set, return the reference sets for which the `assemblyId` matches this string (case-sensitive, exact match).", + "items": { + "type": "string" + }, + "example": [ + "doi:10.15454/312953986E3", + "doi:10.15454/312953986E3" + ] + }, + "md5checksums": { + "type": "array", + "description": "If set, return the reference sets for which the `md5checksum` matches this string (case-sensitive, exact match).", + "items": { + "type": "string" + }, + "example": [ + "c2365e900c81a89cf74d83dab60df146" + ] + }, + "referenceSetDbIds": { + "type": "array", + "description": "The `ReferenceSets` to search.", + "items": { + "type": "string" + }, + "example": [ + "32a19dd7", + "2c182c18" + ] + } + } + } + ], + "brapi-metadata": { + "request": true + } + } + }, + "$id": "https://brapi.org/Specification/BrAPI-Schema/Requests/ReferenceSetRequest.json", + "$schema": "http://json-schema.org/draft/2020-12/schema" +} \ No newline at end of file diff --git a/java/core/src/test/resources/BrAPI-Schema/Requests/SampleRequest.json b/java/core/src/test/resources/BrAPI-Schema/Requests/SampleRequest.json new file mode 100644 index 0000000..280943a --- /dev/null +++ b/java/core/src/test/resources/BrAPI-Schema/Requests/SampleRequest.json @@ -0,0 +1,116 @@ +{ + "$defs": { + "SampleRequest": { + "allOf": [ + { + "$ref": "Parameters/PagingParameters.json#/$defs/PagingParameters" + }, + { + "$ref": "Parameters/GermplasmParameters.json#/$defs/GermplasmParameters" + }, + { + "$ref": "Parameters/CommonCropNamesParameters.json#/$defs/CommonCropNamesParameters" + }, + { + "$ref": "Parameters/ProgramParameters.json#/$defs/ProgramParameters" + }, + { + "$ref": "Parameters/TrialParameters.json#/$defs/TrialParameters" + }, + { + "$ref": "Parameters/StudyParameters.json#/$defs/StudyParameters" + }, + { + "$ref": "Parameters/ExternalReferenceParameters.json#/$defs/ExternalReferenceParameters" + }, + { + "type": "object", + "properties": { + "observationUnitDbIds": { + "description": "The ID which uniquely identifies an `ObservationUnit`", + "items": { + "type": "string" + }, + "type": "array", + "example": [ + "3cd0ca36", + "983f3b14" + ] + }, + "plateDbIds": { + "description": "The ID which uniquely identifies a `Plate` of `Samples`", + "items": { + "type": "string" + }, + "type": "array", + "example": [ + "0cac98b8", + "b96125fb" + ] + }, + "plateNames": { + "description": "The human readable name of a `Plate` of `Samples`", + "items": { + "type": "string" + }, + "type": "array", + "example": [ + "0cac98b8", + "b96125fb" + ] + }, + "sampleDbIds": { + "description": "The ID which uniquely identifies a `Sample`", + "items": { + "type": "string" + }, + "type": "array", + "example": [ + "3bece2ca", + "dd286cc6" + ] + }, + "sampleNames": { + "description": "The human readable name of the `Sample`", + "items": { + "type": "string" + }, + "type": "array", + "example": [ + "SA_111", + "SA_222" + ] + }, + "sampleGroupDbIds": { + "description": "The unique identifier for a group of related `Samples`", + "items": { + "type": "string" + }, + "type": "array", + "example": [ + "45e1e2d7", + "6cc6dd28" + ] + }, + "germplasmDbIds": { + "description": "The ID which uniquely identifies a `Germplasm`", + "items": { + "type": "string" + }, + "type": "array", + "example": [ + "d745e1e2", + "6dd28d74" + ] + } + } + } + ], + "brapi-metadata": { + "request": true + } + } + }, + "$id": "https://brapi.org/Specification/BrAPI-Schema/Requests/SampleRequest.json", + "$schema": "http://json-schema.org/draft/2020-12/schema" +} \ No newline at end of file diff --git a/java/core/src/test/resources/BrAPI-Schema/Requests/ScaleRequest.json b/java/core/src/test/resources/BrAPI-Schema/Requests/ScaleRequest.json new file mode 100644 index 0000000..6d50f46 --- /dev/null +++ b/java/core/src/test/resources/BrAPI-Schema/Requests/ScaleRequest.json @@ -0,0 +1,55 @@ +{ + "$defs": { + "ScaleRequest": { + "allOf": [ + { + "$ref": "Parameters/OntologyParameters.json#/$defs/OntologyParameters" + }, + { + "$ref": "Parameters/PagingParameters.json#/$defs/PagingParameters" + }, + { + "$ref": "Parameters/CommonCropNamesParameters.json#/$defs/CommonCropNamesParameters" + }, + { + "$ref": "Parameters/ProgramParameters.json#/$defs/ProgramParameters" + }, + { + "$ref": "Parameters/ExternalReferenceParameters.json#/$defs/ExternalReferenceParameters" + }, + { + "type": "object", + "properties": { + "scaleDbIds": { + "description": "The unique identifier for a scale.", + "items": { + "type": "string" + }, + "type": "array", + "example": [ + "3cd0ca36", + "983f3b14" + ] + }, + "observationVariableDbIds": { + "description": "The unique identifier for an observation variable.", + "items": { + "type": "string" + }, + "type": "array", + "example": [ + "3cd0ca36", + "983f3b14" + ] + } + } + } + ], + "brapi-metadata": { + "request": true + } + } + }, + "$id": "https://brapi.org/Specification/BrAPI-Schema/Requests/ScaleRequest.json", + "$schema": "http://json-schema.org/draft/2020-12/schema" +} \ No newline at end of file diff --git a/java/core/src/test/resources/BrAPI-Schema/Requests/Schemas/GeoJSONSearchArea.json b/java/core/src/test/resources/BrAPI-Schema/Requests/Schemas/GeoJSONSearchArea.json index e96b015..32db66e 100644 --- a/java/core/src/test/resources/BrAPI-Schema/Requests/Schemas/GeoJSONSearchArea.json +++ b/java/core/src/test/resources/BrAPI-Schema/Requests/Schemas/GeoJSONSearchArea.json @@ -37,7 +37,10 @@ } } } - ] + ], + "brapi-metadata": { + "request": true + } } }, "$id": "https://brapi.org/Specification/BrAPI-Schema/Requests/Schemas/GeoJSONSearchArea.json", diff --git a/java/core/src/test/resources/BrAPI-Schema/Requests/SeasonRequest.json b/java/core/src/test/resources/BrAPI-Schema/Requests/SeasonRequest.json new file mode 100644 index 0000000..f9d0552 --- /dev/null +++ b/java/core/src/test/resources/BrAPI-Schema/Requests/SeasonRequest.json @@ -0,0 +1,67 @@ +{ + "$defs": { + "SeasonRequest": { + "allOf": [ + { + "$ref": "Parameters/PagingParameters.json#/$defs/PagingParameters" + }, + { + "$ref": "Parameters/ExternalReferenceParameters.json#/$defs/ExternalReferenceParameters" + }, + { + "type": "object", + "properties": { + "seasonDbIds": { + "description": "The unique identifier for a season. For backward compatibility it can be a string like '2012', '1957-2004'.", + "items": { + "type": "string" + }, + "type": "array", + "example": [ + "2012", + "1957-2004" + ] + }, + "seasons": { + "description": "The term to describe a given season. Example \"Spring\" OR \"May\" OR \"Planting_Time_7\".", + "items": { + "type": "string" + }, + "type": "array", + "example": [ + "Spring", + "Planting_Time_7" + ] + }, + "seasonNames": { + "description": "The term to describe a given season. Example \"Spring\" OR \"May\" OR \"Planting_Time_7\".", + "items": { + "type": "string" + }, + "type": "array", + "example": [ + "Objective Code One", + "This is a longer objective search query" + ] + }, + "years": { + "description": "The 4 digit year of a season. Example \"2017\"", + "items": { + "type": "string" + }, + "type": "array", + "example": [ + "2017" + ] + } + } + } + ], + "brapi-metadata": { + "request": true + } + } + }, + "$id": "https://brapi.org/Specification/BrAPI-Schema/Requests/SeasonRequest.json", + "$schema": "http://json-schema.org/draft/2020-12/schema" +} \ No newline at end of file diff --git a/java/core/src/test/resources/BrAPI-Schema/Requests/SeedLotRequest.json b/java/core/src/test/resources/BrAPI-Schema/Requests/SeedLotRequest.json new file mode 100644 index 0000000..9189dd3 --- /dev/null +++ b/java/core/src/test/resources/BrAPI-Schema/Requests/SeedLotRequest.json @@ -0,0 +1,54 @@ +{ + "$defs": { + "SeedLotRequest": { + "allOf": [ + { + "$ref": "Parameters/PagingParameters.json#/$defs/PagingParameters" + }, + { + "$ref": "Parameters/ExternalReferenceParameters.json#/$defs/ExternalReferenceParameters" + }, + { + "$ref": "Parameters/CommonCropNamesParameters.json#/$defs/CommonCropNamesParameters" + }, + { + "$ref": "Parameters/ProgramParameters.json#/$defs/ProgramParameters" + }, + { + "$ref": "Parameters/GermplasmParameters.json#/$defs/GermplasmParameters" + }, + { + "type": "object", + "properties": { + "seedLotDbIds": { + "description": "Unique id for a seed lot on this server", + "type": "array", + "items": { + "type": "string" + } + }, + "crossDbIds": { + "description": "Search for Cross with this unique id", + "type": "array", + "items": { + "type": "string" + } + }, + "crossNames": { + "description": "Search for Cross with this human readable name", + "type": "array", + "items": { + "type": "string" + } + } + } + } + ], + "brapi-metadata": { + "request": true + } + } + }, + "$id": "https://brapi.org/Specification/BrAPI-Schema/Requests/SeedLotRequest.json", + "$schema": "http://json-schema.org/draft/2020-12/schema" +} \ No newline at end of file diff --git a/java/core/src/test/resources/BrAPI-Schema/Requests/StudyRequest.json b/java/core/src/test/resources/BrAPI-Schema/Requests/StudyRequest.json new file mode 100644 index 0000000..46bb08a --- /dev/null +++ b/java/core/src/test/resources/BrAPI-Schema/Requests/StudyRequest.json @@ -0,0 +1,119 @@ +{ + "$defs": { + "StudyRequest": { + "allOf": [ + { + "$ref": "Parameters/PagingParameters.json#/$defs/PagingParameters" + }, + { + "$ref": "Parameters/CommonCropNamesParameters.json#/$defs/CommonCropNamesParameters" + }, + { + "$ref": "Parameters/ProgramParameters.json#/$defs/ProgramParameters" + }, + { + "$ref": "Parameters/TrialParameters.json#/$defs/TrialParameters" + }, + { + "$ref": "Parameters/StudyParameters.json#/$defs/StudyParameters" + }, + { + "$ref": "Parameters/LocationParameters.json#/$defs/LocationParameters" + }, + { + "$ref": "Parameters/GermplasmParameters.json#/$defs/GermplasmParameters" + }, + { + "$ref": "Parameters/ObservationVariableParameters.json#/$defs/ObservationVariableParameters" + }, + { + "$ref": "Parameters/ExternalReferenceParameters.json#/$defs/ExternalReferenceParameters" + }, + { + "type": "object", + "properties": { + "active": { + "description": "A flag to indicate if a Study is currently active and ongoing", + "type": "boolean", + "example": true + }, + "seasonDbIds": { + "description": "The ID which uniquely identifies a season", + "items": { + "type": "string" + }, + "type": "array", + "example": [ + "Harvest Two 2017", + "Summer 2018" + ] + }, + "sortBy": { + "description": "Name of one of the fields within the study object on which results can be sorted", + "enum": [ + "studyDbId", + "trialDbId", + "programDbId", + "locationDbId", + "seasonDbId", + "studyType", + "studyName", + "studyLocation", + "programName", + "germplasmDbId", + "observationVariableDbId" + ], + "type": "string" + }, + "sortOrder": { + "description": "Order results should be sorted. ex. \"ASC\" or \"DESC\"", + "enum": [ + "ASC", + "DESC" + ], + "type": "string" + }, + "studyTypes": { + "description": "The type of study being performed. ex. \"Yield Trial\", etc", + "items": { + "type": "string" + }, + "type": "array", + "example": [ + "Yield Trial", + "Disease Resistance Trial" + ] + }, + "studyCodes": { + "description": "A short human readable code for a study", + "items": { + "type": "string" + }, + "type": "array", + "example": [ + "Grape_Yield_Spring_2018", + "Walnut_Kenya" + ] + }, + "studyPUIs": { + "description": "Permanent unique identifier associated with study data. For example, a URI or DOI", + "type": "array", + "items": { + "type": "string" + }, + "example": [ + "doi:10.155454/12349537312", + "https://pui.per/d8dd35e1" + ] + } + } + } + ], + "brapi-metadata": { + "request": true + } + } + }, + "$id": "https://brapi.org/Specification/BrAPI-Schema/Requests/StudyRequest.json", + "$schema": "http://json-schema.org/draft/2020-12/schema" +} \ No newline at end of file diff --git a/java/core/src/test/resources/BrAPI-Schema/Requests/TraitRequest.json b/java/core/src/test/resources/BrAPI-Schema/Requests/TraitRequest.json new file mode 100644 index 0000000..8e21640 --- /dev/null +++ b/java/core/src/test/resources/BrAPI-Schema/Requests/TraitRequest.json @@ -0,0 +1,55 @@ +{ + "$defs": { + "TraitRequest": { + "allOf": [ + { + "$ref": "Parameters/OntologyParameters.json#/$defs/OntologyParameters" + }, + { + "$ref": "Parameters/PagingParameters.json#/$defs/PagingParameters" + }, + { + "$ref": "Parameters/CommonCropNamesParameters.json#/$defs/CommonCropNamesParameters" + }, + { + "$ref": "Parameters/ProgramParameters.json#/$defs/ProgramParameters" + }, + { + "$ref": "Parameters/ExternalReferenceParameters.json#/$defs/ExternalReferenceParameters" + }, + { + "type": "object", + "properties": { + "traitDbIds": { + "description": "The unique identifier for a trait.", + "items": { + "type": "string" + }, + "type": "array", + "example": [ + "3cd0ca36", + "983f3b14" + ] + }, + "observationVariableDbIds": { + "description": "The unique identifier for an observation variable.", + "items": { + "type": "string" + }, + "type": "array", + "example": [ + "3cd0ca36", + "983f3b14" + ] + } + } + } + ], + "brapi-metadata": { + "request": true + } + } + }, + "$id": "https://brapi.org/Specification/BrAPI-Schema/Requests/TraitRequest.json", + "$schema": "http://json-schema.org/draft/2020-12/schema" +} \ No newline at end of file diff --git a/java/core/src/test/resources/BrAPI-Schema/Requests/TrialRequest.json b/java/core/src/test/resources/BrAPI-Schema/Requests/TrialRequest.json new file mode 100644 index 0000000..6b3eb7d --- /dev/null +++ b/java/core/src/test/resources/BrAPI-Schema/Requests/TrialRequest.json @@ -0,0 +1,79 @@ +{ + "$defs": { + "TrialRequest": { + "allOf": [ + { + "$ref": "Parameters/PagingParameters.json#/$defs/PagingParameters" + }, + { + "$ref": "Parameters/CommonCropNamesParameters.json#/$defs/CommonCropNamesParameters" + }, + { + "$ref": "Parameters/ProgramParameters.json#/$defs/ProgramParameters" + }, + { + "$ref": "Parameters/TrialParameters.json#/$defs/TrialParameters" + }, + { + "$ref": "Parameters/StudyParameters.json#/$defs/StudyParameters" + }, + { + "$ref": "Parameters/LocationParameters.json#/$defs/LocationParameters" + }, + { + "$ref": "Parameters/ObservationVariableParameters.json#/$defs/ObservationVariableParameters" + }, + { + "$ref": "Parameters/ExternalReferenceParameters.json#/$defs/ExternalReferenceParameters" + }, + { + "type": "object", + "properties": { + "active": { + "description": "A flag to indicate if a Trial is currently active and ongoing", + "type": "boolean", + "example": true + }, + "contactDbIds": { + "description": "List of contact entities associated with this trial", + "type": "array", + "items": { + "type": "string" + }, + "example": [ + "e0f70c2a", + "b82f0967" + ] + }, + "searchDateRangeStart": { + "description": "The start of the overlapping search date range. `searchDateRangeStart` must be before `searchDateRangeEnd`.\n\nReturn a Trial entity if any of the following cases are true\n\n- `searchDateRangeStart` is before `trial.endDate` AND `searchDateRangeEnd` is null \n\n- `searchDateRangeStart` is before `trial.endDate` AND `searchDateRangeEnd` is after `trial.startDate`\n\n- `searchDateRangeEnd` is after `trial.startDate` AND `searchDateRangeStart` is null\n\n- `searchDateRangeEnd` is after `trial.startDate` AND `searchDateRangeStart` is before `trial.endDate`", + "format": "date", + "type": "string" + }, + "searchDateRangeEnd": { + "description": "The end of the overlapping search date range. `searchDateRangeStart` must be before `searchDateRangeEnd`.\n\nReturn a Trial entity if any of the following cases are true\n\n- `searchDateRangeStart` is before `trial.endDate` AND `searchDateRangeEnd` is null \n\n- `searchDateRangeStart` is before `trial.endDate` AND `searchDateRangeEnd` is after `trial.startDate`\n\n- `searchDateRangeEnd` is after `trial.startDate` AND `searchDateRangeStart` is null\n\n- `searchDateRangeEnd` is after `trial.startDate` AND `searchDateRangeStart` is before `trial.endDate`", + "format": "date", + "type": "string" + }, + "trialPUIs": { + "description": "A permanent identifier for a trial. Could be DOI or other URI formatted identifier.", + "type": "array", + "items": { + "type": "string" + }, + "example": [ + "https://doi.org/01093190", + "https://doi.org/11192409" + ] + } + } + } + ], + "brapi-metadata": { + "request": true + } + } + }, + "$id": "https://brapi.org/Specification/BrAPI-Schema/Requests/TrialRequest.json", + "$schema": "http://json-schema.org/draft/2020-12/schema" +} \ No newline at end of file diff --git a/java/core/src/test/resources/BrAPI-Schema/Requests/VarientRequest.json b/java/core/src/test/resources/BrAPI-Schema/Requests/VarientRequest.json new file mode 100644 index 0000000..e4cd347 --- /dev/null +++ b/java/core/src/test/resources/BrAPI-Schema/Requests/VarientRequest.json @@ -0,0 +1,108 @@ +{ + "$defs": { + "VariantRequest": { + "allOf": [ + { + "$ref": "Parameters/PagingParameters.json#/$defs/PagingParameters" + }, + { + "$ref": "Parameters/CommonCropNamesParameters.json#/$defs/CommonCropNamesParameters" + }, + { + "$ref": "Parameters/ProgramParameters.json#/$defs/ProgramParameters" + }, + { + "$ref": "Parameters/TrialParameters.json#/$defs/TrialParameters" + }, + { + "$ref": "Parameters/StudyParameters.json#/$defs/StudyParameters" + }, + { + "$ref": "Parameters/ExternalReferenceParameters.json#/$defs/ExternalReferenceParameters" + }, + { + "type": "object", + "properties": { + "callSetDbIds": { + "deprecated": true, + "description": "**Deprecated in v2.1** Parameter unnecessary. Github issue number #474 \n
Only return variant calls which belong to call sets with these IDs. If unspecified, return all variants and no variant call objects.", + "items": { + "type": "string" + }, + "type": "array", + "example": [ + "4639fe3e", + "b60d900b" + ] + }, + "end": { + "description": "The end of the window (0-based, exclusive) for which overlapping variants should be returned.", + "type": "integer", + "example": 1500 + }, + "referenceDbId": { + "deprecated": true, + "description": "**Deprecated in v2.1** Please use `referenceDbIds`. Github issue number #472\n
Only return variants on this reference.", + "type": "string", + "example": "120a2d5c" + }, + "referenceDbIds": { + "description": "The unique identifier representing a genotype `Reference`", + "items": { + "type": "string" + }, + "type": "array", + "example": [ + "89ab4d17", + "74d3b63d" + ] + }, + "referenceSetDbIds": { + "description": "The unique identifier representing a genotype `ReferenceSet`", + "items": { + "type": "string" + }, + "type": "array", + "example": [ + "d3b63d4d", + "3b63d74b" + ] + }, + "start": { + "description": "The beginning of the window (0-based, inclusive) for which overlapping variants should be returned. Genomic positions are non-negative integers less than reference length. Requests spanning the join of circular genomes are represented as two requests one on each side of the join (position 0).", + "type": "integer", + "example": 100 + }, + "variantDbIds": { + "description": "A list of IDs which uniquely identify `Variants`", + "items": { + "type": "string" + }, + "type": "array", + "example": [ + "3b63d889", + "ab4d174d" + ] + }, + "variantSetDbIds": { + "description": "A list of IDs which uniquely identify `VariantSets`", + "items": { + "type": "string" + }, + "type": "array", + "example": [ + "ba63d810", + "434d1760" + ] + } + } + } + ], + "brapi-metadata": { + "request": true + } + } + }, + "$id": "https://brapi.org/Specification/BrAPI-Schema/Requests/VariantRequest.json", + "$schema": "http://json-schema.org/draft/2020-12/schema" +} \ No newline at end of file diff --git a/java/core/src/test/resources/BrAPI-Schema/Requests/VarientSetRequest.json b/java/core/src/test/resources/BrAPI-Schema/Requests/VarientSetRequest.json new file mode 100644 index 0000000..bc1959e --- /dev/null +++ b/java/core/src/test/resources/BrAPI-Schema/Requests/VarientSetRequest.json @@ -0,0 +1,91 @@ +{ + "$defs": { + "VariantSetRequest": { + "allOf": [ + { + "$ref": "Parameters/PagingParameters.json#/$defs/PagingParameters" + }, + { + "$ref": "Parameters/CommonCropNamesParameters.json#/$defs/CommonCropNamesParameters" + }, + { + "$ref": "Parameters/ProgramParameters.json#/$defs/ProgramParameters" + }, + { + "$ref": "Parameters/TrialParameters.json#/$defs/TrialParameters" + }, + { + "$ref": "Parameters/StudyParameters.json#/$defs/StudyParameters" + }, + { + "$ref": "Parameters/ExternalReferenceParameters.json#/$defs/ExternalReferenceParameters" + }, + { + "type": "object", + "properties": { + "callSetDbIds": { + "description": "The unique identifier representing a CallSet", + "type": "array", + "items": { + "type": "string" + }, + "example": [ + "9569cfc4", + "da1e888c" + ] + }, + "variantDbIds": { + "description": "The unique identifier representing a Variant", + "type": "array", + "items": { + "type": "string" + }, + "example": [ + "c80f068b", + "eb7c5f50" + ] + }, + "variantSetDbIds": { + "description": "The unique identifier representing a VariantSet", + "type": "array", + "items": { + "type": "string" + }, + "example": [ + "b2903842", + "dcbb8558" + ] + }, + "referenceDbIds": { + "description": "The unique identifier representing a genotype Reference", + "items": { + "type": "string" + }, + "type": "array", + "example": [ + "89ab4d17", + "74d3b63d" + ] + }, + "referenceSetDbIds": { + "description": "The unique identifier representing a genotype ReferenceSet", + "items": { + "type": "string" + }, + "type": "array", + "example": [ + "d3b63d4d", + "3b63d74b" + ] + } + } + } + ], + "brapi-metadata": { + "request": true + } + } + }, + "$id": "https://brapi.org/Specification/BrAPI-Schema/Requests/VariantSetRequest.json", + "$schema": "http://json-schema.org/draft/2020-12/schema" +} \ No newline at end of file diff --git a/java/core/src/test/resources/OpenAPI-Components/Schemas/ContentTypes.yaml b/java/core/src/test/resources/OpenAPI-Components/Schemas/ContentTypes.yaml new file mode 100644 index 0000000..9ae0c67 --- /dev/null +++ b/java/core/src/test/resources/OpenAPI-Components/Schemas/ContentTypes.yaml @@ -0,0 +1,14 @@ +info: + title: BrAPI + version: '' +openapi: 3.0.0 +paths: {} +components: + schemas: + ContentTypes: + enum: + - application/json + - text/csv + - text/tsv + - application/flapjack + type: string \ No newline at end of file diff --git a/java/core/src/test/resources/OpenAPI-Components/Schemas/DataTypes.yaml b/java/core/src/test/resources/OpenAPI-Components/Schemas/DataTypes.yaml deleted file mode 100644 index 6bc9602..0000000 --- a/java/core/src/test/resources/OpenAPI-Components/Schemas/DataTypes.yaml +++ /dev/null @@ -1,35 +0,0 @@ -info: - title: BrAPI - version: '' -openapi: 3.0.0 -paths: {} -components: - schemas: - ContentTypes: - enum: - - application/json - - text/csv - - text/tsv - - application/flapjack - type: string - TraitDataType: - description: |- -

Class of the scale, entries can be

-

"Code" - This scale class is exceptionally used to express complex traits. Code is a nominal scale that combines the expressions of the different traits composing the complex trait. For example a severity trait might be expressed by a 2 digit and 2 character code. The first 2 digits are the percentage of the plant covered by a fungus and the 2 characters refer to the delay in development, e.g. "75VD" means "75 %" of the plant is infected and the plant is very delayed.

-

"Date" - The date class is for events expressed in a time format, See ISO 8601

-

"Duration" - The Duration class is for time elapsed between two events expressed in a time format, e.g. days, hours, months

-

"Nominal" - Categorical scale that can take one of a limited and fixed number of categories. There is no intrinsic ordering to the categories

-

"Numerical" - Numerical scales express the trait with real numbers. The numerical scale defines the unit e.g. centimeter, ton per hectare, branches

-

"Ordinal" - Ordinal scales are scales composed of ordered categories

-

"Text" - A free text is used to express the trait.

- enum: - - Code - - Date - - Duration - - Nominal - - Numerical - - Ordinal - - Text - type: string - example: Numerical - diff --git a/java/core/src/test/resources/graphql-test-options.json b/java/core/src/test/resources/graphql-test-options.json index 9531d92..89e8671 100644 --- a/java/core/src/test/resources/graphql-test-options.json +++ b/java/core/src/test/resources/graphql-test-options.json @@ -1,14 +1,118 @@ { + "pluralFor": { + "AlleleMatrix": "AlleleMatrix" + }, + "input": { + "name": "input", + "nameFormat": "%sInput", + "typeNameFormat": "%sInput" + }, "queryType": { - "generate": true, "name": "Query", + "partitionedByCrop": true, "singleQuery": { - "descriptionFormat": "Returns a %s object by id" + "generate": true, + "nameFormat": "%s", + "descriptionFormat": "Returns a %s object by id", + "generateFor": { + "AlleleMatrix": false, + "Call": false, + "Cross": false, + "Event": false, + "MarkerPosition": false, + "PlannedCross": false + } + }, + "listQuery": { + "generate": true, + "nameFormat": "%s", + "descriptionFormat": "Returns %s objects", + "responseTypeNameFormat": "%sListResponse", + "dataFieldName": "data", + "pagedDefault": true, + "paged": { + "BreedingMethod": false + }, + "input": { + "BreedingMethod": false, + "CrossingProject": true + }, + "generateFor": { + "AlleleMatrix": false + }, + "pagingInputName": "paging", + "pageInputTypeName": "PageInput", + "pageTypeName": "PageInfo", + "pageFieldName": "page" + }, + "searchQuery": { + "generate": true, + "nameFormat": "%sSearch", + "descriptionFormat": "Returns %s objects", + "responseTypeNameFormat": "%sResponse", + "searchIdFieldName": "searchDbId", + "generateFor": { + "AlleleMatrix": false, + "BreedingMethod": false, + "Cross": false, + "CrossProject": false, + "Method": false, + "Ontology": false, + "Scale": false, + "Trait": false + } } }, "mutationType": { - "generate": false, - "name": "Mutation" + "name": "Mutation", + "createMutation": { + "generate": true, + "nameFormat": "create%s", + "descriptionFormat": "Update the details for an existing %s", + "generateFor": { + "AlleleMatrix": false, + "Call": false, + "CallSet": false, + "Cross": false, + "Event": false, + "GenomeMap": false, + "MarkerPosition": false, + "Reference": false, + "Variant": false + } + }, + "updateMutation": { + "generate": true, + "nameFormat": "update%s", + "descriptionFormat": "Update the details for an existing %s", + "generateFor": { + "AlleleMatrix": false, + "Call": false, + "CallSet": false, + "Cross": false, + "Event": false, + "GenomeMap": false, + "MarkerPosition": false, + "Reference": false, + "Variant": false + } + }, + "deleteMutation": { + "generate": false, + "descriptionFormat": "Delete existing %s", + "nameFormat": "delete%s", + "generateFor": { + "AlleleMatrix": false, + "Call": false, + "CallSet": false, + "Event": false, + "GenomeMap": false, + "MarkerPosition": false, + "Reference": false, + "Variant": false, + "VariantSet": false + } + } }, "ids": { "useIDType": true, diff --git a/java/core/src/test/resources/graphql-test-options.yaml b/java/core/src/test/resources/graphql-test-options.yaml index a29337e..62009ca 100644 --- a/java/core/src/test/resources/graphql-test-options.yaml +++ b/java/core/src/test/resources/graphql-test-options.yaml @@ -1,29 +1,100 @@ +pluralFor: + AlleleMatrix: AlleleMatrix +input: + name: input + nameFormat: "%sInput" + typeNameFormat: "%sInput" queryType: - generate: true name: Query + partitionedByCrop: true singleQuery: generate: true + nameFormat: "%s" descriptionFormat: Returns a %s object by id + generateFor: + AlleleMatrix: false + Call: false + Cross: false + Event: false + MarkerPosition: false + PlannedCross: false listQuery: generate: true + nameFormat: "%s" descriptionFormat: Returns %s objects - inputName: input - inputNameFormat: "%sInput" responseTypeNameFormat: "%sListResponse" dataFieldName: data pagedDefault: true paged: BreedingMethod: false + input: + BreedingMethod: false + CrossingProject: true + generateFor: + AlleleMatrix: false pagingInputName: paging pageInputTypeName: PageInput pageTypeName: PageInfo pageFieldName: page searchQuery: generate: true + nameFormat: "%sSearch" descriptionFormat: Returns %s objects + responseTypeNameFormat: "%sResponse" + searchIdFieldName: searchDbId + generateFor: + AlleleMatrix: false + BreedingMethod: false + Cross: false + CrossProject: false + Method: false + Ontology: false + Scale: false + Trait: false mutationType: - generate: false name: Mutation + createMutation: + generate: true + nameFormat: create%s + descriptionFormat: Update the details for an existing %s + generateFor: + AlleleMatrix: false + Call: false + CallSet: false + Cross: false + Event: false + GenomeMap: false + MarkerPosition: false + Reference: false + Variant: false + updateMutation: + generate: true + nameFormat: update%s + descriptionFormat: Update the details for an existing %s + generateFor: + AlleleMatrix: false + Call: false + CallSet: false + Cross: false + Event: false + GenomeMap: false + MarkerPosition: false + Reference: false + Variant: false + deleteMutation: + generate: false + descriptionFormat: Delete existing %s + nameFormat: delete%s + generateFor: + AlleleMatrix: false + Call: false + CallSet: false + Event: false + GenomeMap: false + MarkerPosition: false + Reference: false + Variant: false + VariantSet: false ids: useIDType: true nameFormat: "%sDbId" \ No newline at end of file diff --git a/java/core/src/test/resources/openapi-test-options.json b/java/core/src/test/resources/openapi-test-options.json index b68dabb..b44776e 100644 --- a/java/core/src/test/resources/openapi-test-options.json +++ b/java/core/src/test/resources/openapi-test-options.json @@ -1,19 +1,129 @@ { + "separateByModule": false, + "generateNewRequest": true, + "generateNewRequestFor": { + "AlleleMatrix": false, + "BreedingMethod": false, + "Call": false, + "CallSet": false, + "Event": false, + "GenomeMap": false, + "MarkerPosition": false, + "Reference": false, + "PedigreeNode": false, + "PlannedCross": false, + "Season": false, + "Variant": false, + "VariantSet": false + }, + "newRequestNameFormat": "%sNewRequest", + "singleResponseNameFormat": "%sSingleResponse", + "listResponseNameFormat": "%sListResponse", + "searchRequestNameFormat": "%sSearchRequest", + "pluralFor": { + "AlleleMatrix": "AlleleMatrix" + }, + "pathItemNameFor": { + "PedigreeNode": "pedigrees" + }, "singleGet": { "generate": true, - "descriptionFormat": "Returns a %s object by id" + "summaryFormat": "Get the details of a specific %s", + "descriptionFormat": "Get details for a %s", + "generateFor": { + "AlleleMatrix": false, + "Call": false, + "Cross": false, + "Event": false, + "MarkerPosition": false, + "PlannedCross": false + } }, "listGet": { "generate": true, - "descriptionFormat": "Returns a %s object by id" + "summaryFormat": "Get a filtered list of %s", + "descriptionFormat": "Get a list of %s", + "generateFor": { + "AlleleMatrix": false + }, + "pagedDefault": true, + "paged": { + "BreedingMethod": false + }, + "inputFor": { + "BreedingMethod": false + } + }, + "search": { + "generate": true, + "summaryFormat": "Submit a search request for `%s`", + "descriptionFormat": "Submit a search request for `%s`t", + "submitDescriptionFormat": "Submit a search request for `%s`
\nSearch requests allow a client to send a complex query for data. However, the server may not respond with the search results immediately. \nIf a server needs more time to process the request, it might respond with a `searchResultsDbId`. \nUse the corresponding `GET /search/%s/{searchResultsDbId}` to retrieve the results of the search.
\nReview the Search Services documentation for additional implementation details.", + "retrieveDescriptionFormat": "Get the results of a `%s` search request
\nClients should submit a search request using the corresponding `POST /search/%s` endpoint.\nSearch requests allow a client to send a complex query for data. However, the server may not respond with the search results immediately. \nIf a server needs more time to process the request, it might respond with a `searchResultsDbId`. \nUse this endpoint to retrieve the results of the search.
\nReview the Search Services documentation for additional implementation details.", + "generateFor": { + "AlleleMatrix": false, + "BreedingMethod": false, + "Cross": false, + "CrossProject": false, + "Method": false, + "Ontology": false, + "Scale": false, + "Trait": false + } }, "post": { - "generate": true + "generate": true, + "summaryFormat": "Create new %s", + "descriptionFormat": "Add new %s to database", + "generateFor": { + "AlleleMatrix": false, + "Call": false, + "CallSet": false, + "Event": false, + "GenomeMap": false, + "MarkerPosition": false, + "Reference": false, + "Variant": false, + "VariantSet": false + } }, "put": { - "generate": true + "generate": true, + "summaryFormat": "Update the details for an existing %s", + "descriptionFormat": "Update the details for an existing %s", + "generateFor": { + "AlleleMatrix": false, + "Call": false, + "CallSet": false, + "Cross": false, + "Event": false, + "GenomeMap": false, + "MarkerPosition": false, + "Reference": false, + "Variant": false + } }, "delete": { - "generate": false + "generate": false, + "summaryFormat": "Delete an existing %s", + "descriptionFormat": "Delete existing %s", + "generateFor": { + "AlleleMatrix": false, + "Call": false, + "CallSet": false, + "Event": false, + "GenomeMap": false, + "MarkerPosition": false, + "Reference": false, + "Variant": false, + "VariantSet": false + } + }, + "ids": { + "nameFormat": "%sDbId", + "parameterFor": { + "GermplasmAttribute": "attributeDbId", + "GermplasmAttributeValue": "attributeValueDbId" + } } } \ No newline at end of file diff --git a/java/core/src/test/resources/openapi-test-options.yaml b/java/core/src/test/resources/openapi-test-options.yaml index 55e135d..0cbbd2d 100644 --- a/java/core/src/test/resources/openapi-test-options.yaml +++ b/java/core/src/test/resources/openapi-test-options.yaml @@ -1,12 +1,119 @@ +separateByModule: false +generateNewRequest: true +generateNewRequestFor: + AlleleMatrix: false + BreedingMethod: false + Call: false + CallSet: false + Event: false + GenomeMap: false + MarkerPosition: false + Reference: false + PedigreeNode: false + PlannedCross: false + Season: false + Variant: false + VariantSet: false +newRequestNameFormat: "%sNewRequest" +singleResponseNameFormat: "%sSingleResponse" +listResponseNameFormat: "%sListResponse" +searchRequestNameFormat: "%sSearchRequest" +pluralFor: + AlleleMatrix: AlleleMatrix +pathItemNameFor: + PedigreeNode: pedigrees singleGet: generate: true - descriptionFormat: Returns a %s object by id + summaryFormat: Get the details of a specific %s + descriptionFormat: Get details for a %s + generateFor: + AlleleMatrix: false + Call: false + Cross: false + Event: false + MarkerPosition: false + PlannedCross: false listGet: generate: true - descriptionFormat: Returns a %s object by id + summaryFormat: Get a filtered list of %s + descriptionFormat: Get a list of %s + generateFor: + AlleleMatrix: false + pagedDefault: true + paged: + BreedingMethod: false + inputFor: + BreedingMethod: false +search: + generate: true + summaryFormat: Submit a search request for `%s` + descriptionFormat: Submit a search request for `%s`t + submitDescriptionFormat: |- + Submit a search request for `%s`
+ Search requests allow a client to send a complex query for data. However, the server may not respond with the search results immediately. + If a server needs more time to process the request, it might respond with a `searchResultsDbId`. + Use the corresponding `GET /search/%s/{searchResultsDbId}` to retrieve the results of the search.
+ Review the Search Services documentation for additional implementation details. + retrieveDescriptionFormat: |- + Get the results of a `%s` search request
+ Clients should submit a search request using the corresponding `POST /search/%s` endpoint. + Search requests allow a client to send a complex query for data. However, the server may not respond with the search results immediately. + If a server needs more time to process the request, it might respond with a `searchResultsDbId`. + Use this endpoint to retrieve the results of the search.
+ Review the Search Services documentation for additional implementation details. + generateFor: + AlleleMatrix: false + BreedingMethod: false + Cross: false + CrossProject: false + Method: false + Ontology: false + Scale: false + Trait: false post: generate: true + summaryFormat: Create new %s + descriptionFormat: Add new %s to database + generateFor: + AlleleMatrix: false + Call: false + CallSet: false + Event: false + GenomeMap: false + MarkerPosition: false + Reference: false + Variant: false + VariantSet: false put: generate: true + summaryFormat: Update the details for an existing %s + descriptionFormat: Update the details for an existing %s + generateFor: + AlleleMatrix: false + Call: false + CallSet: false + Cross: false + Event: false + GenomeMap: false + MarkerPosition: false + Reference: false + Variant: false delete: - generate: false \ No newline at end of file + generate: false + summaryFormat: Delete an existing %s + descriptionFormat: Delete existing %s + generateFor: + AlleleMatrix: false + Call: false + CallSet: false + Event: false + GenomeMap: false + MarkerPosition: false + Reference: false + Variant: false + VariantSet: false +ids: + nameFormat: "%sDbId" + parameterFor: + GermplasmAttribute: attributeDbId + GermplasmAttributeValue: attributeValueDbId \ No newline at end of file