-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[feat] Intro GeneratorMetadata (stability index) #2816
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
9a592da
[feat] Intro GeneratorMetadata (stability index)
jimschubert c9866e5
Mark deprecated generators as deprecated in-code
jimschubert b60552f
Re-export docs/generators.md
jimschubert dfd3e9c
Add missing javadoc for GeneratorMetadata newBuilder copy param
jimschubert 048a237
Regenerate docs/generators.md
jimschubert 8375fa8
Merge branch 'master' into stability-indexing
jimschubert File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NOTE: We could apply
Stability
to other things as well, such as the templating engine adapters.