Class OpenAPIGeneratorOptions

java.lang.Object
org.brapi.schematools.core.options.AbstractGeneratorOptions
org.brapi.schematools.core.openapi.generator.options.OpenAPIGeneratorOptions
All Implemented Interfaces:
Options, Validatable

public class OpenAPIGeneratorOptions extends AbstractGeneratorOptions
Options for the OpenAPIGenerator.
  • Constructor Details

    • OpenAPIGeneratorOptions

      public OpenAPIGeneratorOptions()
  • Method Details

    • load

      public static OpenAPIGeneratorOptions load()
      Load the default options
      Returns:
      The default options
    • load

      public static OpenAPIGeneratorOptions load(Path optionsFile) throws IOException
      Load the options from an options file in YAML or Json. The options file may have missing (defined) values, in these cases the default values are loaded. See load()
      Parameters:
      optionsFile - The path to the options file in YAML or Json.
      Returns:
      The options loaded from the YAML or Json file.
      Throws:
      IOException - if the options file can not be found or is incorrectly formatted.
    • load

      public static OpenAPIGeneratorOptions load(InputStream inputStream) throws IOException
      Load the options from an options input stream in YAML or Json. The options file may have missing (defined) values, in these cases the default values are loaded. See load()
      Parameters:
      inputStream - The input stream in YAML or Json.
      Returns:
      The options loaded from input stream.
      Throws:
      IOException - if the input stream is not valid or the content is incorrectly formatted.
    • override

      public OpenAPIGeneratorOptions override(OpenAPIGeneratorOptions overrideOptions)
      Overrides the values in this Options Object from the provided Options Object if they are non-null
      Parameters:
      overrideOptions - the options which will be used to override this Options Object
      Returns:
      this object for method chaining
    • validate

      public Validation validate()
      Description copied from interface: Validatable
      Checks if the Validatable object is valid, return a list of errors if it is not valid
      Returns:
      a Validation object than can be used queried to find if the object is valid and any errors if it is not valid
    • isSeparatingByModule

      public boolean isSeparatingByModule()
      Determines if the Generator should generate a separate specification per module.
      Returns:
      true if the Generator should generate a separate specification per module, false otherwise
    • isGeneratingEndpoint

      public boolean isGeneratingEndpoint()
      Determines if the Generator should generate any Endpoints without an ID parameter. Returns true if AbstractGeneratorSubOptions.isGenerating() or AbstractGeneratorSubOptions.isGenerating() or AbstractGeneratorSubOptions.isGenerating() is set to true
      Returns:
      true if the Generator should generate any Endpoints without an ID parameter, false otherwise
    • isGeneratingEndpointFor

      public boolean isGeneratingEndpointFor(@NonNull @NonNull String name)
      Determines if the Generator should generate the Endpoints without an ID parameter for a specific Primary Model. Returns true if AbstractGeneratorSubOptions.isGeneratingFor(String) or AbstractGeneratorSubOptions.isGeneratingFor(String) is set to true
      Parameters:
      name - the name of the Primary Model
      Returns:
      true if the Generator should generate the Endpoints without an ID parameter for a specific Primary Model, false otherwise
    • isGeneratingEndpointFor

      public boolean isGeneratingEndpointFor(@NonNull @NonNull BrAPIType type)
      Determines if the Generator should generate the Endpoints without an ID parameter for a specific Primary Model. Returns true if AbstractGeneratorSubOptions.isGeneratingFor(String) or AbstractGeneratorSubOptions.isGeneratingFor(String) is set to true
      Parameters:
      type - the Primary Model
      Returns:
      true if the Generator should generate the Endpoints without an ID parameter for a specific Primary Model, false otherwise
    • isGeneratingEndpointWithId

      public boolean isGeneratingEndpointWithId()
      Determines if the Generator should generate any Endpoints with an ID parameter. Returns true if AbstractGeneratorSubOptions.isGenerating() or AbstractGeneratorSubOptions.isGenerating() or AbstractGeneratorSubOptions.isGenerating() is set to true
      Returns:
      true if the Generator should generate any Endpoints without an ID parameter, false otherwise
    • isGeneratingEndpointNameWithIdFor

      public boolean isGeneratingEndpointNameWithIdFor(@NonNull @NonNull String name)
      Determines if the Generator should generate the Endpoints with an ID parameter for a specific Primary Model. Returns true if AbstractGeneratorSubOptions.isGeneratingFor(String) or PutOptions.isGeneratingEndpointNameWithIdFor(String) or AbstractGeneratorSubOptions.isGeneratingFor(String)is set to true
      Parameters:
      name - the name of the Primary Model
      Returns:
      true if the Generator should generate the Endpoints with an ID parameter for a specific Primary Model, false otherwise
    • isGeneratingEndpointNameWithIdFor

      public final boolean isGeneratingEndpointNameWithIdFor(@NonNull @NonNull BrAPIType type)
      Determines if the Generator should generate the Endpoints with an ID parameter for a specific Primary Model. Returns true if AbstractGeneratorSubOptions.isGeneratingFor(String) or PutOptions.isGeneratingEndpointNameWithIdFor(String) or AbstractGeneratorSubOptions.isGeneratingFor(String)is set to true
      Parameters:
      type - the Primary Model
      Returns:
      true if the Generator should generate the Endpoints with an ID parameter for a specific Primary Model, false otherwise
    • getSupplementalSpecificationFor

      public String getSupplementalSpecificationFor(@NonNull @NonNull String name)
    • isGeneratingNewRequestFor

      public boolean isGeneratingNewRequestFor(@NonNull @NonNull String name)
      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
      Parameters:
      name - the name of the Primary Model
      Returns:
      true if the Generator should generate a NewRequest schema, separate from the standard schema for a specific Primary Model, false otherwise
    • isGeneratingNewRequestFor

      public final boolean isGeneratingNewRequestFor(@NonNull @NonNull BrAPIType type)
      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
      Parameters:
      type - the Primary Model
      Returns:
      true if the Generator should generate a NewRequest schema, separate from the standard schema for a specific Primary Model, false otherwise
    • getNewRequestNameFor

      public String getNewRequestNameFor(@NonNull @NonNull String name)
      Gets the name for the NewRequest schema for a specific Primary Model
      Parameters:
      name - the name of the Primary Model
      Returns:
      the NewRequest schema name for a specific Primary Model
    • getNewRequestNameFor

      public final String getNewRequestNameFor(@NonNull @NonNull BrAPIType type)
      Gets the name for the NewRequest schema for a specific Primary Model
      Parameters:
      type - the Primary Model
      Returns:
      the NewRequest schema name for a specific Primary Model
    • getSingleResponseNameFor

      public String getSingleResponseNameFor(@NonNull @NonNull String name)
      Gets the name for the Single Response schema for a specific Primary Model
      Parameters:
      name - the name of the Primary Model
      Returns:
      the Single Response schema name for a specific Primary Model
    • getSingleResponseNameFor

      public final String getSingleResponseNameFor(@NonNull @NonNull BrAPIType type)
      Gets the name for the Single Response schema for a specific Primary Model
      Parameters:
      type - the Primary Model
      Returns:
      the Single Response schema name for a specific Primary Model
    • getListResponseNameFor

      public final String getListResponseNameFor(@NonNull @NonNull String name)
      Gets the name for the List Response for a specific Primary Model
      Parameters:
      name - the name of the Primary Model
      Returns:
      the List Response name for a specific Primary Model
    • getListResponseNameFor

      public final String getListResponseNameFor(@NonNull @NonNull BrAPIType type)
      Gets the name for the List Response for a specific Primary Model
      Parameters:
      type - the Primary Model
      Returns:
      the List Response name for a specific Primary Model
    • getListResponseNameFor

      public final String getListResponseNameFor(@NonNull @NonNull BrAPIObjectTypeWithProperty typeWithProperty)
      Gets the name for the List Response for a specific Primary Model
      Parameters:
      type - the Primary Model
      Returns:
      the List Response name for a specific Primary Model
    • getSearchRequestNameFor

      public final String getSearchRequestNameFor(@NonNull @NonNull String name)
      Gets the name for the Search Request schema for a specific Primary Model
      Parameters:
      name - the name of the Primary Model
      Returns:
      the Search Request schema name for a specific Primary Model
    • getSearchRequestNameFor

      public final String getSearchRequestNameFor(@NonNull @NonNull BrAPIType type)
      Gets the name for the Search Request schema for a specific Primary Model
      Parameters:
      type - the Primary Model
      Returns:
      the Search Request schema name for a specific Primary Model
    • getSingularForProperty

      public final String getSingularForProperty(@NonNull @NonNull String propertyName)
      Gets the singular name for pluralised property name
      Parameters:
      propertyName - the pluralised property name
      Returns:
      the Pluralise name for a specific Primary Model
    • getPathItemNameFor

      public String getPathItemNameFor(String name)
      Gets the path item name for a specific Primary Model
      Parameters:
      name - the name of the Primary Model
      Returns:
      the Pluralised name for a specific Primary Model
    • getPathItemNameFor

      public String getPathItemNameFor(BrAPIType type)
      Gets the path item name for a specific Primary Model
      Parameters:
      type - the Primary Model
      Returns:
      the path item name for a specific Primary Model
    • getPathItemWithIdNameFor

      public String getPathItemWithIdNameFor(BrAPIType type)
      Gets the path item with id name for a specific Primary Model
      Parameters:
      type - the Primary Model
      Returns:
      the path item name for a specific Primary Model
    • getPathItemNameForProperty

      public final String getPathItemNameForProperty(@NonNull @NonNull String typeName, @NonNull @NonNull String propertyName)
      Gets the path item name for a specific BrAPI Property
      Parameters:
      typeName - the name of the primary model
      propertyName - the name of the property
      Returns:
      the path item name for the Property
    • getPathItemNameForProperty

      public final String getPathItemNameForProperty(@NonNull @NonNull BrAPIType type, @NonNull @NonNull BrAPIObjectProperty property)
      Gets the path item name for a specific BrAPI Property
      Parameters:
      type - the primary model
      property - the property
      Returns:
      the path item name for the Property
    • getPathItemNameForProperty

      public String getPathItemNameForProperty(@NonNull @NonNull BrAPIObjectTypeWithProperty typeWithProperty)
      Gets the path item name for a specific BrAPI Property
      Parameters:
      typeWithProperty - the primary model with the property
      Returns:
      the path item name for the Property
    • setPathItemNameForProperty

      public OpenAPIGeneratorOptions setPathItemNameForProperty(String typeName, String propertyName, String pathItemName)
      Sets the path item name for a specific BrAPI Property
      Parameters:
      typeName - the name of the primary model
      propertyName - the name of the property
      pathItemName - the path item name
      Returns:
      the options for chaining
    • setPathItemNameForProperty

      public OpenAPIGeneratorOptions setPathItemNameForProperty(@NonNull @NonNull BrAPIType type, @NonNull @NonNull BrAPIObjectProperty property, String pathItemName)
      Sets the path item name for a specific BrAPI Property
      Parameters:
      type - the primary model
      property - the property
      pathItemName - the path item name
      Returns:
      the options for chaining
    • getTagFor

      public final String getTagFor(@NonNull @NonNull String name)
      Gets the tag name for a specific Primary Model. If not set AbstractGeneratorOptions.getPluralFor(String) will be used. Use setTagFor(String, String) to override this value.
      Parameters:
      name - the name of the Primary Model
      Returns:
      the tag name for a specific Primary Model
    • getTagFor

      public final String getTagFor(@NonNull @NonNull BrAPIType type)
      Gets the tag name for a specific Primary Model. If not set AbstractGeneratorOptions.getPluralFor(String) will be used. Use setTagFor(String, String) to override this value.
      Parameters:
      type - the Primary Model
      Returns:
      the tag name for a specific Primary Model
    • setTagFor

      public AbstractGeneratorOptions setTagFor(String name, String tagName)
      Sets the tag name for a specific primary model.
      Parameters:
      name - the name of the primary model
      tagName - the tag name for a specific primary model.
      Returns:
      the options for chaining
    • isGeneratingSubPathFor

      public boolean isGeneratingSubPathFor(BrAPIObjectType type, BrAPIObjectProperty property)
      Determines if a specific property should be exposed as a separate Endpoint
      Parameters:
      type - the Object type
      property - the Object type property
      Returns:
      true generator will create a separate Endpoint for the property, false otherwise
    • getSubPathItemNameFor

      public String getSubPathItemNameFor(String pathItemName, BrAPIObjectProperty property)
      Gets the name of the Sub-path endpoint for a property
      Parameters:
      pathItemName - the path prefix
      property - the Object type property
      Returns:
      the name of the Sub-path endpoint for a property
    • isGeneratingControlledVocabularyEndpoints

      public boolean isGeneratingControlledVocabularyEndpoints()
      Determines Controlled vocabulary endpoints should be generated. Any entity which as a property that is indicated in the metadata that it returns a controlled vocabulary will have an endpoint generated in the format /invalid input: '<'entity-plural>/invalid input: '<'property-name-plural> for example /attributes/categories
      Returns:
      true if controlled vocabulary endpoints should be generated