diff --git a/java/buildSrc/src/main/groovy/brapi.schema-tools.java-conventions.gradle b/java/buildSrc/src/main/groovy/brapi.schema-tools.java-conventions.gradle index 991fc98..653bc89 100644 --- a/java/buildSrc/src/main/groovy/brapi.schema-tools.java-conventions.gradle +++ b/java/buildSrc/src/main/groovy/brapi.schema-tools.java-conventions.gradle @@ -3,7 +3,7 @@ plugins { } group = 'org.brapi' -version = '0.11.0-SNAPSHOT' +version = '0.12.0-SNAPSHOT' sourceCompatibility = JavaVersion.VERSION_21 targetCompatibility = JavaVersion.VERSION_21 diff --git a/java/core/src/main/java/org/brapi/schematools/core/openapi/options/PropertiesOptions.java b/java/core/src/main/java/org/brapi/schematools/core/openapi/options/PropertiesOptions.java index 5700926..d706c19 100644 --- a/java/core/src/main/java/org/brapi/schematools/core/openapi/options/PropertiesOptions.java +++ b/java/core/src/main/java/org/brapi/schematools/core/openapi/options/PropertiesOptions.java @@ -69,6 +69,15 @@ public List getLinkPropertiesFor(BrAPIObjectType brAPIObjec return linkProperties ; } + /** + * Gets the id parameter name for a type + * @param type The BrAPI type + * @return the id parameter name for a type + */ + public String getIdPropertyNameFor(String type) { + return id.getPropertyNameFor(type) ; + } + /** * Gets the id parameter name for a type * @param type The BrAPI type diff --git a/java/core/src/main/java/org/brapi/schematools/core/utils/ConfigurationUtils.java b/java/core/src/main/java/org/brapi/schematools/core/utils/ConfigurationUtils.java index 33a1ace..5acfcee 100644 --- a/java/core/src/main/java/org/brapi/schematools/core/utils/ConfigurationUtils.java +++ b/java/core/src/main/java/org/brapi/schematools/core/utils/ConfigurationUtils.java @@ -16,8 +16,7 @@ public class ConfigurationUtils { private static final ObjectMapper mapper = new ObjectMapper(new YAMLFactory()); /** - * Load the configurations from a file in YAML or Json. The file may have missing - * (defined) values, in these cases the default values are loaded. + * Load the configurations from a file in YAML or Json. * @param configurationsFile The path to the configuration file in YAML or Json. * @param configurationClass The configuration class. * @param the class of the configuration @@ -45,8 +44,7 @@ public static T load(String classPath, Class configurationClass) throws I } /** - * Load the configurations from an input stream in YAML or Json. The configuration file may have missing - * (defined) values, in these cases the default values are loaded. + * Load the configurations from an input stream in YAML or Json. * @param inputStream The input stream in YAML or Json * @param configurationClass The configuration class. * @param the class of the configuration 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 3a9eb91..40bc142 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 @@ -47,6 +47,22 @@ void loadYaml() { checkOptions(options); } + @Test + void overwrite() { + GraphQLGeneratorOptions options = null; + try { + options = GraphQLGeneratorOptions.load(Path.of(ClassLoader.getSystemResource("graphql-overwrite-options.yaml").toURI())); + } catch (IOException | URISyntaxException e) { + e.printStackTrace(); + fail(e.getMessage()); + } + + checkOptions(options); + + assertEquals("attributeDbId", options.getIds().getIDFieldFor("GermplasmAttribute")) ; + assertEquals("attributeDbId", options.getIds().getIDFieldFor("CultivarAttribute")) ; + } + private void checkOptions(GraphQLGeneratorOptions options) { assertNotNull(options); 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 5f1152f..39f9154 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 @@ -53,171 +53,19 @@ void loadYaml() { } @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() { - } + void overwrite() { + OpenAPIGeneratorOptions options = null; + try { + options = OpenAPIGeneratorOptions.load(Path.of(ClassLoader.getSystemResource("openapi-overwrite-options.yaml").toURI())); + } catch (IOException | URISyntaxException e) { + e.printStackTrace(); + fail(e.getMessage()); + } - @Test - void builder() { - } + checkOptions(options); - @Test - void toBuilder() { + assertEquals("attributeDbId", options.getProperties().getIdPropertyNameFor("GermplasmAttribute")) ; + assertEquals("attributeDbId", options.getProperties().getIdPropertyNameFor("CultivarAttribute")) ; } private void checkOptions(OpenAPIGeneratorOptions options) { diff --git a/java/core/src/test/resources/graphql-overwrite-options.yaml b/java/core/src/test/resources/graphql-overwrite-options.yaml new file mode 100644 index 0000000..8a31f40 --- /dev/null +++ b/java/core/src/test/resources/graphql-overwrite-options.yaml @@ -0,0 +1,124 @@ +pluralFor: + AlleleMatrix: AlleleMatrix +ids: + useIDType: true + nameFormat: "%sDbId" + fieldFor: + CultivarAttribute: attributeDbId + CultivarAttributeValue: attributeValueDbId + GermplasmAttribute: attributeDbId + GermplasmAttributeValue: attributeValueDbId + LocaleAttribute: attributeDbId + LocaleAttributeValue: attributeValueDbId + ObservationUnitAttribute: attributeDbId + ObservationUnitAttributeValue: attributeValueDbId + SeedLotAttribute: attributeDbId + SeedLotAttributeValue: attributeValueDbId +input: + name: input + nameFormat: "%sInput" + typeNameFormat: "%sInput" +queryType: + 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 + 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 + pluralisingName: true + nameFormat: "%sSearch" + descriptionFormat: Returns %s objects + responseTypeNameFormat: "%sResponse" + searchIdFieldName: searchResultsDbId + generateFor: + AlleleMatrix: false + BreedingMethod: false + Cross: false + CrossProject: false + Method: false + Ontology: false + Scale: false + Trait: false +mutationType: + 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 + PedigreeNode: 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 + PedigreeNode: false + Reference: false + Variant: false + deleteMutation: + generate: false + pluralisingName: true + multiple: true + nameFormat: delete%s + descriptionFormat: Delete existing %s + generateFor: + AlleleMatrix: false + Call: false + CallSet: false + Event: false + GenomeMap: false + MarkerPosition: false + PedigreeNode: false + Reference: false + Variant: false + VariantSet: false +mergeOneOfType: true +mergingOneOfTypeFor: + GeoJSONGeometry: false \ No newline at end of file diff --git a/java/core/src/test/resources/openapi-overwrite-options.yaml b/java/core/src/test/resources/openapi-overwrite-options.yaml new file mode 100644 index 0000000..cce72e3 --- /dev/null +++ b/java/core/src/test/resources/openapi-overwrite-options.yaml @@ -0,0 +1,159 @@ +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 + 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. + 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 + BreedingMethod: 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 + BreedingMethod: 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 +properties: + id: + nameFormat: "%sDbId" + link: true + propertyFor: + CultivarAttribute: attributeDbId + CultivarAttributeValue: attributeValueDbId + GermplasmAttribute: attributeDbId + GermplasmAttributeValue: attributeValueDbId + LocaleAttribute: attributeDbId + LocaleAttributeValue: attributeValueDbId + ObservationUnitAttribute: attributeDbId + ObservationUnitAttributeValue: attributeValueDbId + SeedLotAttribute: attributeDbId + SeedLotAttributeValue: attributeValueDbId + name: + nameFormat: "%sName" + link: true + propertyFor: + CultivarAttribute: attributeName + CultivarAttributeValue: attributeValueName + GermplasmAttribute: attributeName + GermplasmAttributeValue: attributeValueName + LocaleAttribute: attributeName + LocaleAttributeValue: attributeValueName + ObservationUnitAttribute: attributeName + ObservationUnitAttributeValue: attributeValueName + SeedLotAttribute: attributeName + SeedLotAttributeValue: attributeValueName + pui: + nameFormat: "%sPUI" + link: true + propertyFor: + CultivarAttribute: attributePUI + CultivarAttributeValue: attributeValuePUI + GermplasmAttribute: attributePUI + GermplasmAttributeValue: attributeValuePUI + LocaleAttribute: attributePUI + LocaleAttributeValue: attributeValuePUI + ObservationUnitAttribute: attributePUI + ObservationUnitAttributeValue: attributeValuePUI + SeedLotAttribute: attributePUI + SeedLotAttributeValue: attributeValuePUI \ No newline at end of file