Skip to content

Commit

Permalink
fixed javadocs
Browse files Browse the repository at this point in the history
  • Loading branch information
Guy Davenport committed Oct 11, 2024
1 parent e2642bc commit cd3b983
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

import picocli.CommandLine;

/**
* Main class for the BrAPI application
*/
@CommandLine.Command(
name = "brapi",
description = "Command line tools for the BrAPI JSON schema, see the sub-commands for details",
Expand All @@ -14,6 +17,11 @@
mixinStandardHelpOptions = true
)
public class BrAPICommand {

/**
* Main method for application
* @param args arguments for application
*/
public static void main(String[] args) {
new CommandLine(new BrAPICommand()).execute(args);
}
Expand Down
16 changes: 16 additions & 0 deletions java/cli/src/main/java/org/brapi/schematools/cli/OutputFormat.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,24 @@
package org.brapi.schematools.cli;

/**
* Enumeration that provides the possible outputs for generator
*/
public enum OutputFormat {

/**
* Use this format to generate an OpenAPI specification
*/
OPEN_API,
/**
* Use this format to generate an GraphQL schema
*/
GRAPHQL,
/**
* Use this format to generate OWL specification in turtle format
*/
OWL,
/**
* Use this format to generate Markdown for type and their field descriptions
*/
MARKDOWN
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
import java.nio.file.Path;
import java.util.List;

/**
* The Validate Sub-command
*/
@CommandLine.Command(
name = "validate", mixinStandardHelpOptions = true,
description = "Validates the BrAPI JSON schema"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package org.brapi.schematools.core.markdown;

import graphql.schema.GraphQLSchema;
import lombok.AllArgsConstructor;
import org.brapi.schematools.core.brapischema.BrAPISchemaReader;
import org.brapi.schematools.core.graphql.options.GraphQLGeneratorOptions;
import org.brapi.schematools.core.model.BrAPIClass;
import org.brapi.schematools.core.model.BrAPIEnumType;
import org.brapi.schematools.core.model.BrAPIObjectProperty;
Expand All @@ -21,18 +23,31 @@

import static org.brapi.schematools.core.response.Response.fail;
import static org.brapi.schematools.core.response.Response.success;

/**
* Generates a Markdown files for type and their field descriptions from a BrAPI Json Schema.
*/
@AllArgsConstructor
public class MarkdownGenerator {
private final BrAPISchemaReader schemaReader = new BrAPISchemaReader() ;

private Path outputPath ;
private boolean overwrite ;

/**
* Generates Markdown files for type and their field descriptions
* from the complete BrAPI Specification in
* a directory contains a subdirectories for each module that contain
* 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.
* @param schemaDirectory the path to the complete BrAPI Specification
* @return the paths of the Markdown files generated from the complete BrAPI Specification
*/
public Response<List<Path>> generate(Path schemaDirectory) {
return schemaReader.readDirectories(schemaDirectory).mapResultToResponse(brAPISchemas -> new MarkdownGenerator.Generator(brAPISchemas).generate()) ;
}

public class Generator {
private class Generator {

private final List<BrAPIClass> brAPISchemas ;
private final Path descriptionsPath ;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,14 @@ public Validation validate() {
.assertNotNull(id, "'id' option on %s is null", this.getClass().getSimpleName()) ;
}


/**
* Gets the list of link properties that are used to generate links to the
* provided object type.
*
* This is usually the object dbId, but can also be the name and/or PUI.
* @param brAPIObjectType the object type from which the properties will be obtained
* @return list of link properties that are used to generate links to the object
*/
public List<BrAPIObjectProperty> getLinkPropertiesFor(BrAPIObjectType brAPIObjectType) {
List<BrAPIObjectProperty> linkProperties = new ArrayList<>() ;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ public Validation validate() {

/**
* Gets the property name for a specific primary model. For example the id property (or field)
* name of Study, would be 'studyDbiId' by default. Use {@link #setIDParameterFor} to override this value.
* name of Study, would be 'studyDbiId' by default. Use {@link #setPropertyNameFor(String, String)}
* to override this value.
* @param name the name of the primary model
* @return property name for a specific primary model
*/
Expand All @@ -50,7 +51,8 @@ public String getPropertyNameFor(String name) {

/**
* Gets the property name for a specific primary model. For example the id property (or field)
* name of Study, would be 'studyDbiId' by default. Use {@link #setIDParameterFor} to override this value.
* name of Study, would be 'studyDbiId' by default. Use {@link #setPropertyNameFor(String, String)}
* to override this value.
* @param type the primary model
* @return property name for a specific primary model
*/
Expand Down Expand Up @@ -86,7 +88,8 @@ public PropertyOptions setPropertyNameFor(BrAPIType type, String parameterName)

/**
* Gets the plural property name for a specific primary model. For example the id property (or field)
* name of Study, would be 'studyDbiId' by default. Use {@link #setIDParameterFor} to override this value.
* name of Study, would be 'studyDbiId' by default. Use {@link #setPluralPropertyNameFor} to
* override this value.
* @param name the name of the primary model
* @return property name for a specific primary model
*/
Expand All @@ -97,7 +100,8 @@ public String getPluralPropertyNameFor(String name) {

/**
* Gets the plural property name for a specific primary model. For example the id property (or field)
* name of Study, would be 'studyDbiId' by default. Use {@link #setIDParameterFor} to override this value.
* name of Study, would be 'studyDbiId' by default. Use {@link #setPluralPropertyNameFor}
* to override this value.
* @param type the primary model
* @return property name for a specific primary model
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package org.brapi.schematools.core.valdiation;

/**
* Interface that markers a class that can be validated.
*/
public interface Validatable {
/**
* Checks if the Validatable object is valid, return a list of errors if it is not valid
Expand Down

0 comments on commit cd3b983

Please sign in to comment.