-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[feat] Intro GeneratorMetadata (stability index) (#2816)
* [feat] Intro GeneratorMetadata (stability index) GeneratorMetadata offers an immutable object created via Builder pattern which allows generators to explicitly define their stability (stable, beta, experimental, deprecated) as well as a message to be shown during generation. This is a step toward: * Fleshing out the "Core" artifact (#845) * Providing a place to encapsulate feature-oriented metadata (#840) * Providing a means to communicate end of life scheduling (#116) This new structure, specifically the Stability property, allows us to offer future enhancements such as allowing users to filter down to only "Stable" generators via CLI, and eventually any compat table (see #503). * Mark deprecated generators as deprecated in-code * Re-export docs/generators.md
- Loading branch information
1 parent
26d0487
commit 6e1c897
Showing
11 changed files
with
225 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
99 changes: 99 additions & 0 deletions
99
...openapi-generator-core/src/main/java/org/openapitools/codegen/meta/GeneratorMetadata.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
package org.openapitools.codegen.meta; | ||
|
||
/** | ||
* Represents metadata about a generator. | ||
*/ | ||
public class GeneratorMetadata { | ||
private Stability stability; | ||
private String generationMessage; | ||
|
||
private GeneratorMetadata(Builder builder) { | ||
stability = builder.stability; | ||
generationMessage = builder.generationMessage; | ||
} | ||
|
||
/** | ||
* Creates a new builder object for {@link GeneratorMetadata}. | ||
* | ||
* @return A new builder instance. | ||
*/ | ||
public static Builder newBuilder() { | ||
return new Builder(); | ||
} | ||
|
||
/** | ||
* Creates a new builder object for {@link GeneratorMetadata}, accepting another instance from which to copy properties. | ||
* | ||
* @param copy An existing instance to copy defaults from | ||
* | ||
* @return A new builder instance, with values preset to those of 'copy'. | ||
*/ | ||
public static Builder newBuilder(GeneratorMetadata copy) { | ||
Builder builder = new Builder(); | ||
if (copy != null) { | ||
builder.stability = copy.getStability(); | ||
builder.generationMessage = copy.getGenerationMessage(); | ||
} | ||
return builder; | ||
} | ||
|
||
/** | ||
* Returns a message which can be displayed during generation. | ||
* | ||
* @return A message, if defined. | ||
*/ | ||
public String getGenerationMessage() { | ||
return generationMessage; | ||
} | ||
|
||
/** | ||
* Returns an enum describing the stability index of the generator. | ||
* | ||
* @return The defined stability index. | ||
*/ | ||
public Stability getStability() { | ||
return stability; | ||
} | ||
|
||
/** | ||
* {@code GeneratorMetadata} builder static inner class. | ||
*/ | ||
public static final class Builder { | ||
private Stability stability; | ||
private String generationMessage; | ||
|
||
private Builder() { | ||
} | ||
|
||
/** | ||
* Sets the {@code stability} and returns a reference to this Builder so that the methods can be chained together. | ||
* | ||
* @param stability the {@code stability} to set | ||
* @return a reference to this Builder | ||
*/ | ||
public Builder stability(Stability stability) { | ||
this.stability = stability; | ||
return this; | ||
} | ||
|
||
/** | ||
* Sets the {@code generationMessage} and returns a reference to this Builder so that the methods can be chained together. | ||
* | ||
* @param generationMessage the {@code generationMessage} to set | ||
* @return a reference to this Builder | ||
*/ | ||
public Builder generationMessage(String generationMessage) { | ||
this.generationMessage = generationMessage; | ||
return this; | ||
} | ||
|
||
/** | ||
* Returns a {@code GeneratorMetadata} built from the parameters previously set. | ||
* | ||
* @return a {@code GeneratorMetadata} built with parameters of this {@code GeneratorMetadata.Builder} | ||
*/ | ||
public GeneratorMetadata build() { | ||
return new GeneratorMetadata(this); | ||
} | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
modules/openapi-generator-core/src/main/java/org/openapitools/codegen/meta/Stability.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package org.openapitools.codegen.meta; | ||
|
||
/** | ||
* Represents the "stability index" of a generator or feature, based on the stability indexes defined in the node.js ecosystem. | ||
*/ | ||
public enum Stability { | ||
/** | ||
* The feature or features are considered complete and "production-ready". | ||
*/ | ||
STABLE("stable"), | ||
/** | ||
* The feature may be partially incomplete, but breaking changes will be avoided between major releases. | ||
*/ | ||
BETA("beta"), | ||
/** | ||
* The feature is still under active development and subject to non-backward compatible changes or removal in any | ||
* future version. Use of the feature is not recommended in production environments. | ||
*/ | ||
EXPERIMENTAL("experimental"), | ||
/** | ||
* The feature may emit warnings. Backward compatibility is not guaranteed. Removal is likely to occur in a subsequent major release. | ||
*/ | ||
DEPRECATED("deprecated"); | ||
|
||
private String description; | ||
|
||
Stability(String description) { | ||
this.description = description; | ||
} | ||
|
||
/** | ||
* Returns a value for this stability index. | ||
* | ||
* @return The descriptive value of this enum. | ||
*/ | ||
public String value() { return description; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters