[core] Initial FeatureSet structures and definitions (#3614)

[core] Initial FeatureSet structures and definitions
Add default feature set to DefaultCodegen
Initial FeatureSet definitions for:

*  ada 
*  android 
*  apache2 
*  asciidoc 
*  aspnetcore 
*  avro 
*  bash 
*  c 
*  clojure 
*  cpp-pistache-server 
*  cpp-qt5-client 
*  cpp-qt5-qhttpengine-server 
*  cpp-restbed-server 
*  cpp-restsdk 
*  cpp-tizen 
*  csharp 
*  csharp-nancyfx 
*  csharp-netcore 
*  cwiki 
*  dart 
*  eiffel 
*  elixir 
*  elm 
*  erlang 
*  flash 
*  fsharp-functions 
*  go  Client/Server
*  graphql-nodejs-express-server 
*  graphql-schema 
*  groovy 
*  haskell 
*  haskell-http-client 
*  java 
*  jmeter 
*  kotlin 
*  kotlin vertx 
*  kotlin-server 
*  kotlin-spring 
*  lua 
*  mysql 
*  nim 
*  nodejs 
*  nodejs-express 
*  objc 
*  ocaml 
*  openapi 
*  openapi-yaml 
*  perl 
*  php 
*  php-laravel 
*  php-lumen 
*  php-silex 
*  php-slim 
*  php-symfony 
*  php-ze-ph 
*  powershell 
*  protobuf 
*  protobuf-schema 
*  python 
*  python-aiohttp 
*  python-blueplanet 
*  python-experimental 
*  r 
*  ror 
*  ruby 
*  ruby 
*  ruby-sinatra 
*  rust 
*  scala-akka 
*  scala-finch 
*  scala-gatling 
*  scala-http-client 
*  scala-lagom 
*  scala-play 
*  scalatra 
*  scalaz 
*  spring 
*  static docs 
*  swift 
*  typescript
This commit is contained in:
Jim Schubert
2020-01-11 16:20:47 -05:00
committed by GitHub
parent 4627c7d534
commit 78bf3adc4a
291 changed files with 5116 additions and 583 deletions

View File

@@ -0,0 +1,530 @@
/*
* Copyright 2019 OpenAPI-Generator Contributors (https://openapi-generator.tech)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.openapitools.codegen.meta;
import org.openapitools.codegen.meta.features.*;
import java.util.Arrays;
import java.util.EnumSet;
import java.util.stream.Collectors;
/**
* Defines the feature set for a target generator.
*/
@SuppressWarnings({"unused", "WeakerAccess"})
public class FeatureSet {
public static FeatureSet UNSPECIFIED = FeatureSet.newBuilder().build();
private EnumSet<ClientModificationFeature> clientModificationFeatures;
private EnumSet<DataTypeFeature> dataTypeFeatures;
private EnumSet<DocumentationFeature> documentationFeatures;
private EnumSet<GlobalFeature> globalFeatures;
private EnumSet<SchemaSupportFeature> schemaSupportFeatures;
private EnumSet<ParameterFeature> parameterFeatures;
private EnumSet<SecurityFeature> securityFeatures;
private EnumSet<WireFormatFeature> wireFormatFeatures;
private FeatureSet(Builder builder) {
if (builder != null) {
clientModificationFeatures = builder.clientModificationFeatures;
dataTypeFeatures = builder.dataTypeFeatures;
documentationFeatures = builder.documentationFeatures;
schemaSupportFeatures = builder.schemaSupportFeatures;
globalFeatures = builder.globalFeatures;
parameterFeatures = builder.parameterFeatures;
securityFeatures = builder.securityFeatures;
wireFormatFeatures = builder.wireFormatFeatures;
}
}
public Builder modify() {
return FeatureSet.newBuilder(this);
}
public static Builder newBuilder() {
return new Builder();
}
public static Builder newBuilder(FeatureSet copy) {
Builder builder = new Builder();
if (copy != null) {
builder.clientModificationFeatures = copy.getClientModificationFeatures();
builder.dataTypeFeatures = copy.getDataTypeFeatures();
builder.documentationFeatures = copy.getDocumentationFeatures();
builder.schemaSupportFeatures = copy.getSchemaSupportFeatures();
builder.globalFeatures = copy.getGlobalFeatures();
builder.parameterFeatures = copy.getParameterFeatures();
builder.securityFeatures = copy.getSecurityFeatures();
builder.wireFormatFeatures = copy.getWireFormatFeatures();
}
return builder;
}
/**
* Returns the set of client modification features supported by the generator.
*
* @return A new copy of the defined feature set. Changes to this instance are not promoted.
*/
public EnumSet<ClientModificationFeature> getClientModificationFeatures() {
if (clientModificationFeatures != null) {
return EnumSet.copyOf(clientModificationFeatures);
} else {
return EnumSet.noneOf(ClientModificationFeature.class);
}
}
/**
* Returns the set of common data types supported by the generator
*
* @return A new copy of the defined feature set. Changes to this instance are not promoted.
*/
public EnumSet<DataTypeFeature> getDataTypeFeatures() {
if (dataTypeFeatures != null) {
return EnumSet.copyOf(dataTypeFeatures);
} else {
return EnumSet.noneOf(DataTypeFeature.class);
}
}
/**
* Returns the documentation type available in generated output.
*
* @return A new copy of the defined feature set. Changes to this instance are not promoted.
*/
public EnumSet<DocumentationFeature> getDocumentationFeatures() {
if (documentationFeatures != null) {
return EnumSet.copyOf(documentationFeatures);
} else {
return EnumSet.noneOf(DocumentationFeature.class);
}
}
/**
* Returns special circumstances handled by the generator.
*
* @return A new copy of the defined feature set. Changes to this instance are not promoted.
*/
public EnumSet<SchemaSupportFeature> getSchemaSupportFeatures() {
if (schemaSupportFeatures != null) {
return EnumSet.copyOf(schemaSupportFeatures);
} else {
return EnumSet.noneOf(SchemaSupportFeature.class);
}
}
/**
* Returns the spec features supported "globally" for a document (shared across all operations and/or models).
*
* @return A new copy of the defined feature set. Changes to this instance are not promoted.
*/
public EnumSet<GlobalFeature> getGlobalFeatures() {
if (globalFeatures != null) {
return EnumSet.copyOf(globalFeatures);
} else {
return EnumSet.noneOf(GlobalFeature.class);
}
}
/**
* Returns the types of parameters supported by endpoints in the generated code.
*
* @return A new copy of the defined feature set. Changes to this instance are not promoted.
*/
public EnumSet<ParameterFeature> getParameterFeatures() {
if (parameterFeatures != null) {
return EnumSet.copyOf(parameterFeatures);
} else {
return EnumSet.noneOf(ParameterFeature.class);
}
}
/**
* Returns the security features supported in the generated code.
*
* @return A new copy of the defined feature set. Changes to this instance are not promoted.
*/
public EnumSet<SecurityFeature> getSecurityFeatures() {
if (securityFeatures != null) {
return EnumSet.copyOf(securityFeatures);
} else {
return EnumSet.noneOf(SecurityFeature.class);
}
}
/**
* Returns the wire format options officially supported by the generated code.
*
* @return A new copy of the defined feature set. Changes to this instance are not promoted.
*/
public EnumSet<WireFormatFeature> getWireFormatFeatures() {
if (wireFormatFeatures != null) {
return EnumSet.copyOf(wireFormatFeatures);
} else {
return EnumSet.noneOf(WireFormatFeature.class);
}
}
/**
* {@code FeatureSet} builder static inner class.
*/
public static final class Builder {
private EnumSet<ClientModificationFeature> clientModificationFeatures;
private EnumSet<DataTypeFeature> dataTypeFeatures;
private EnumSet<DocumentationFeature> documentationFeatures;
private EnumSet<SchemaSupportFeature> schemaSupportFeatures;
private EnumSet<GlobalFeature> globalFeatures;
private EnumSet<ParameterFeature> parameterFeatures;
private EnumSet<SecurityFeature> securityFeatures;
private EnumSet<WireFormatFeature> wireFormatFeatures;
private Builder() {
this.clientModificationFeatures = EnumSet.noneOf(ClientModificationFeature.class);
this.dataTypeFeatures = EnumSet.noneOf(DataTypeFeature.class);
this.documentationFeatures = EnumSet.noneOf(DocumentationFeature.class);
this.schemaSupportFeatures = EnumSet.noneOf(SchemaSupportFeature.class);
this.parameterFeatures = EnumSet.noneOf(ParameterFeature.class);
this.securityFeatures = EnumSet.noneOf(SecurityFeature.class);
this.globalFeatures = EnumSet.noneOf(GlobalFeature.class);
this.wireFormatFeatures = EnumSet.noneOf(WireFormatFeature.class);
}
/**
* Sets the {@code clientModificationFeatures} and returns a reference to this Builder so that the methods can be chained together.
*
* @param clientModificationFeatures the {@code clientModificationFeatures} to set
* @return a reference to this Builder
*/
public Builder clientModificationFeatures(EnumSet<ClientModificationFeature> clientModificationFeatures) {
if (clientModificationFeatures != null) {
this.clientModificationFeatures = clientModificationFeatures;
} else {
this.clientModificationFeatures = EnumSet.noneOf(ClientModificationFeature.class);
}
return this;
}
/**
* Includes the defined {@link ClientModificationFeature} to the new/existing set of supported features.
*
* @param clientModificationFeature One or more {@code clientModificationFeature} to ensure are included in the set.
*
* @return a reference to this Builder
*/
public Builder includeClientModificationFeatures(ClientModificationFeature... clientModificationFeature) {
this.clientModificationFeatures.addAll(Arrays.stream(clientModificationFeature).collect(Collectors.toList()));
return this;
}
/**
* Excludes the defined {@link ClientModificationFeature} from the set of supported features.
*
* @param clientModificationFeature One or more {@code clientModificationFeature} to ensure are excluded from the set.
*
* @return a reference to this Builder
*/
public Builder excludeClientModificationFeatures(ClientModificationFeature... clientModificationFeature) {
this.clientModificationFeatures.removeAll(Arrays.stream(clientModificationFeature).collect(Collectors.toList()));
return this;
}
/**
* Sets the {@code dataTypeFeatures} and returns a reference to this Builder so that the methods can be chained together.
*
* @param dataTypeFeatures the {@code dataTypeFeatures} to set
* @return a reference to this Builder
*/
public Builder dataTypeFeatures(EnumSet<DataTypeFeature> dataTypeFeatures) {
if (dataTypeFeatures != null) {
this.dataTypeFeatures = dataTypeFeatures;
} else {
this.dataTypeFeatures = EnumSet.noneOf(DataTypeFeature.class);
}
return this;
}
/**
* Includes the defined {@link DataTypeFeature} to the new/existing set of supported features.
*
* @param dataTypeFeature One or more {@code dataTypeFeature} to ensure are included in the set.
*
* @return a reference to this Builder
*/
public Builder includeDataTypeFeatures(DataTypeFeature... dataTypeFeature) {
this.dataTypeFeatures.addAll(Arrays.stream(dataTypeFeature).collect(Collectors.toList()));
return this;
}
/**
* Excludes the defined {@link DataTypeFeature} from the set of supported features.
*
* @param dataTypeFeature One or more {@code dataTypeFeature} to ensure are excluded from the set.
*
* @return a reference to this Builder
*/
public Builder excludeDataTypeFeatures(DataTypeFeature... dataTypeFeature) {
this.dataTypeFeatures.removeAll(Arrays.stream(dataTypeFeature).collect(Collectors.toList()));
return this;
}
/**
* Sets the {@code documentationFeature} and returns a reference to this Builder so that the methods can be chained together.
*
* @param documentationFeatures the {@code documentationFeature} to set
* @return a reference to this Builder
*/
public Builder documentationFeatures(EnumSet<DocumentationFeature> documentationFeatures) {
if (documentationFeatures != null) {
this.documentationFeatures = documentationFeatures;
} else {
this.documentationFeatures = EnumSet.noneOf(DocumentationFeature.class);
}
return this;
}
/**
* Includes the defined {@link DocumentationFeature} to the new/existing set of supported features.
*
* @param documentationFeature One or more {@code documentationFeature} to ensure are included in the set.
*
* @return a reference to this Builder
*/
public Builder includeDocumentationFeatures(DocumentationFeature... documentationFeature) {
this.documentationFeatures.addAll(Arrays.stream(documentationFeature).collect(Collectors.toList()));
return this;
}
/**
* Excludes the defined {@link DocumentationFeature} from the set of supported features.
*
* @param documentationFeature One or more {@code documentationFeature} to ensure are excluded from the set.
*
* @return a reference to this Builder
*/
public Builder excludeDocumentationFeatures(DocumentationFeature... documentationFeature) {
this.documentationFeatures.removeAll(Arrays.stream(documentationFeature).collect(Collectors.toList()));
return this;
}
/**
* Sets the {@code schemaSupportFeature} and returns a reference to this Builder so that the methods can be chained together.
*
* @param schemaSupportFeatures the {@code schemaSupportFeature} to set
* @return a reference to this Builder
*/
public Builder schemaSupportFeatures(EnumSet<SchemaSupportFeature> schemaSupportFeatures) {
if (schemaSupportFeatures != null) {
this.schemaSupportFeatures = schemaSupportFeatures;
} else {
this.schemaSupportFeatures = EnumSet.noneOf(SchemaSupportFeature.class);
}
return this;
}
/**
* Includes the defined {@link SchemaSupportFeature} to the new/existing set of supported features.
*
* @param schemaSupportFeature One or more {@code schemaSupportFeature} to ensure are included in the set.
*
* @return a reference to this Builder
*/
public Builder includeSchemaSupportFeatures(SchemaSupportFeature... schemaSupportFeature) {
this.schemaSupportFeatures.addAll(Arrays.stream(schemaSupportFeature).collect(Collectors.toList()));
return this;
}
/**
* Excludes the defined {@link SchemaSupportFeature} from the set of supported features.
*
* @param schemaSupportFeature One or more {@code schemaSupportFeature} to ensure are excluded from the set.
*
* @return a reference to this Builder
*/
public Builder excludeSchemaSupportFeatures(SchemaSupportFeature... schemaSupportFeature) {
this.schemaSupportFeatures.removeAll(Arrays.stream(schemaSupportFeature).collect(Collectors.toList()));
return this;
}
/**
* Sets the {@code parameterFeature} and returns a reference to this Builder so that the methods can be chained together.
*
* @param parameterFeatures the {@code parameterFeature} to set
* @return a reference to this Builder
*/
public Builder parameterFeatures(EnumSet<ParameterFeature> parameterFeatures) {
if (parameterFeatures != null) {
this.parameterFeatures = parameterFeatures;
} else {
this.parameterFeatures = EnumSet.noneOf(ParameterFeature.class);
}
return this;
}
/**
* Includes the defined {@link ParameterFeature} to the new/existing set of supported features.
*
* @param parameterFeature One or more {@code parameterFeature} to ensure are included in the set.
*
* @return a reference to this Builder
*/
public Builder includeParameterFeatures(ParameterFeature... parameterFeature) {
this.parameterFeatures.addAll(Arrays.stream(parameterFeature).collect(Collectors.toList()));
return this;
}
/**
* Excludes the defined {@link ParameterFeature} from the set of supported features.
*
* @param parameterFeature One or more {@code parameterFeature} to ensure are excluded from the set.
*
* @return a reference to this Builder
*/
public Builder excludeParameterFeatures(ParameterFeature... parameterFeature) {
this.parameterFeatures.removeAll(Arrays.stream(parameterFeature).collect(Collectors.toList()));
return this;
}
/**
* Sets the {@code securityFeature} and returns a reference to this Builder so that the methods can be chained together.
*
* @param securityFeatures the {@code securityFeatures} to set
* @return a reference to this Builder
*/
public Builder securityFeatures(EnumSet<SecurityFeature> securityFeatures) {
if (securityFeatures != null) {
this.securityFeatures = securityFeatures;
} else {
this.securityFeatures = EnumSet.noneOf(SecurityFeature.class);
}
return this;
}
/**
* Includes the defined {@link SecurityFeature} to the new/existing set of supported features.
*
* @param securityFeature One or more {@code securityFeature} to ensure are included in the set.
*
* @return a reference to this Builder
*/
public Builder includeSecurityFeatures(SecurityFeature... securityFeature) {
this.securityFeatures.addAll(Arrays.stream(securityFeature).collect(Collectors.toList()));
return this;
}
/**
* Excludes the defined {@link SecurityFeature} from the set of supported features.
*
* @param securityFeature One or more {@code securityFeature} to ensure are excluded from the set.
*
* @return a reference to this Builder
*/
public Builder excludeSecurityFeatures(SecurityFeature... securityFeature) {
this.securityFeatures.removeAll(Arrays.stream(securityFeature).collect(Collectors.toList()));
return this;
}
/**
* Sets the {@code globalFeatures} and return a reference to this Builder so that the methods can be chained together.
*
* @param globalFeatures the {@code globalFeatures} to set
* @return a reference to this Builder
*/
public Builder globalFeatures(EnumSet<GlobalFeature> globalFeatures) {
if (globalFeatures != null) {
this.globalFeatures = globalFeatures;
} else {
this.globalFeatures = EnumSet.noneOf(GlobalFeature.class);
}
return this;
}
/**
* Includes the defined {@link GlobalFeature} to the new/existing set of supported features.
*
* @param globalFeature One or more {@code globalFeatures} to ensure are included in the set.
*
* @return a reference to this Builder
*/
public Builder includeGlobalFeatures(GlobalFeature... globalFeature) {
this.globalFeatures.addAll(Arrays.stream(globalFeature).collect(Collectors.toList()));
return this;
}
/**
* Excludes the defined {@link GlobalFeature} from the set of supported features.
*
* @param globalFeature One or more {@code globalFeatures} to ensure are excluded from the set.
*
* @return a reference to this Builder
*/
public Builder excludeGlobalFeatures(GlobalFeature... globalFeature) {
this.globalFeatures.removeAll(Arrays.stream(globalFeature).collect(Collectors.toList()));
return this;
}
/**
* Sets the {@code wireFormatFeatures} and return a reference to this Builder so that the methods can be chained together.
*
* @param wireFormatFeatures the {@code wireFormatFeatures} to set
* @return a reference to this Builder
*/
public Builder wireFormatFeatures(EnumSet<WireFormatFeature> wireFormatFeatures) {
if (wireFormatFeatures != null) {
this.wireFormatFeatures = wireFormatFeatures;
} else {
this.wireFormatFeatures = EnumSet.noneOf(WireFormatFeature.class);
}
return this;
}
/**
* Includes the defined {@link WireFormatFeature} to the new/existing set of supported features.
*
* @param wireFormatFeature One or more {@code wireFormatFeatures} to ensure are included in the set.
*
* @return a reference to this Builder
*/
public Builder includeWireFormatFeatures(WireFormatFeature... wireFormatFeature) {
this.wireFormatFeatures.addAll(Arrays.stream(wireFormatFeature).collect(Collectors.toList()));
return this;
}
/**
* Excludes the defined {@link WireFormatFeature} from the set of supported features.
*
* <p>
* This option should only be used if something is overtly broken or not possible in a generator. Please log a warning if invoking this method.
* </p>
*
* @param wireFormatFeature One or more {@code wireFormatFeatures} to ensure are excluded from the set.
*
* @return a reference to this Builder
*/
public Builder excludeWireFormatFeatures(WireFormatFeature... wireFormatFeature) {
this.wireFormatFeatures.removeAll(Arrays.stream(wireFormatFeature).collect(Collectors.toList()));
return this;
}
/**
* Returns a {@code FeatureSet} built from the parameters previously set.
*
* @return a {@code FeatureSet} built with parameters of this {@code FeatureSet.Builder}
*/
public FeatureSet build() {
return new FeatureSet(this);
}
}
}

View File

@@ -16,16 +16,29 @@
package org.openapitools.codegen.meta;
import org.openapitools.codegen.meta.features.*;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.Map;
/**
* Represents metadata about a generator.
*/
@SuppressWarnings("WeakerAccess")
public class GeneratorMetadata {
private Stability stability;
private Map<String, FeatureSet> libraryFeatures;
private FeatureSet featureSet;
private String generationMessage;
private GeneratorMetadata(Builder builder) {
stability = builder.stability;
generationMessage = builder.generationMessage;
if (builder != null) {
stability = builder.stability;
generationMessage = builder.generationMessage;
libraryFeatures = builder.libraryFeatures;
featureSet = builder.featureSet;
}
}
/**
@@ -37,18 +50,13 @@ public class GeneratorMetadata {
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();
builder.libraryFeatures = copy.getLibraryFeatures();
builder.featureSet = copy.getFeatureSet();
}
return builder;
}
@@ -71,12 +79,32 @@ public class GeneratorMetadata {
return stability;
}
/**
* Returns the feature set supported by the generator.
*
* @return The set of available features.
*/
public FeatureSet getFeatureSet() {
return featureSet;
}
/**
* Returns the list of features supported by generator libraries.
*
* @return A map of library name to feature set for that library.
*/
public Map<String, FeatureSet> getLibraryFeatures() {
return libraryFeatures;
}
/**
* {@code GeneratorMetadata} builder static inner class.
*/
public static final class Builder {
private Stability stability;
private String generationMessage;
private FeatureSet featureSet = FeatureSet.UNSPECIFIED;
private Map<String, FeatureSet> libraryFeatures = new HashMap<>();
private Builder() {
}
@@ -92,6 +120,32 @@ public class GeneratorMetadata {
return this;
}
/**
* Sets the {@code featureSet} and returns a reference to this Builder so that the methods can be chained together.
*
* @param featureSet the {@code featureSet} to set
* @return a reference to this Builder
*/
public Builder featureSet(FeatureSet featureSet) {
if (featureSet != null) {
this.featureSet = featureSet;
} else {
this.featureSet = FeatureSet.UNSPECIFIED;
}
return this;
}
/**
* Sets the {@code libraryFeatures} and returns a reference to this Builder so that the methods can be chained together.
*
* @param libraryFeatures the {@code libraryFeatures} to set
* @return a reference to this Builder
*/
public Builder libraryFeatures(Map<String, FeatureSet> libraryFeatures) {
this.libraryFeatures = libraryFeatures;
return this;
}
/**
* Sets the {@code generationMessage} and returns a reference to this Builder so that the methods can be chained together.
*

View File

@@ -0,0 +1,42 @@
/*
* Copyright 2019 OpenAPI-Generator Contributors (https://openapi-generator.tech)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.openapitools.codegen.meta.features;
import org.openapitools.codegen.meta.features.annotations.ToolingExtension;
/**
* Defines a general set of modifications supported by a generated client.
*/
public enum ClientModificationFeature {
/**
* Supports defining a custom overall base path in generated client output.
*/
@ToolingExtension
BasePath,
/**
* Supports customizing authorizations in generated client output.
*/
@ToolingExtension
Authorizations,
/**
* Supports customizing the user agent in generated client output.
*/
@ToolingExtension
UserAgent
}

View File

@@ -0,0 +1,240 @@
/*
* Copyright 2019 OpenAPI-Generator Contributors (https://openapi-generator.tech)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.openapitools.codegen.meta.features;
import org.openapitools.codegen.meta.features.annotations.OAS2;
import org.openapitools.codegen.meta.features.annotations.OAS3;
import org.openapitools.codegen.meta.features.annotations.ToolingExtension;
/**
* Defines common data types supported by a generator.
* Some of these features are defined in specs, and some are specific to the tool.
*
* Where data types are listed as tool-specific, this either indicates that the data type is common enough that it is an officially
* supported custom data type by the toolset (see {@link DataTypeFeature#Decimal}), or that the consideration of a special type isn't
* explicitly mentioned by the specification(s) but differs enough across languages that it warrants a special callout (see {@link DataTypeFeature#ArrayOfModel}).
*/
public enum DataTypeFeature {
/**
* Supports a generator-specific support usually via type=string's format property (e.g. email, uuid, etc), should be documented in generator README.
*
* <p>Loosely described in OpenAPI Specification(s). Generally means a custom "format" option applied to a string-typed property.</p>
*/
@OAS2 @OAS3
Custom,
/**
* Supports integer/int32
*/
@OAS2 @OAS3
Int32,
/**
* Supports integer/int64
*/
@OAS2 @OAS3
Int64,
/**
* Supports number/float
*/
@OAS2 @OAS3
Float,
/**
* Supports number/double
*/
@OAS2 @OAS3
Double,
/**
* Supports number/decimal (a special case for some languages)
*
* <p>Decimal is not a type defined by OAS 2.0 specification</p>
*/
@ToolingExtension
Decimal,
/**
* Supports string
*/
@OAS2 @OAS3
String,
/**
* Supports string/byte: base64 encoded
*/
@OAS2 @OAS3
Byte,
/**
* Supports string/binary: any collection of octets
*/
@OAS2 @OAS3
Binary,
/**
* Supports boolean
*/
@OAS2 @OAS3
Boolean,
/**
* Supports string/date: full-date RFC3339
*
* @see <a href="https://tools.ietf.org/html/rfc3339">RFC3339</a>
*/
@OAS2 @OAS3
Date,
/**
* Supports string/date-time: date-time RFC3339
*
* @see <a href="https://tools.ietf.org/html/rfc3339">RFC3339</a>
*/
@OAS2 @OAS3
DateTime,
/**
* Supports string/password: A hint to UIs to obscure input.
*
*
* <p>
* This should be used as an indicator for password best practices, such as assigning a variable to
* a character array rather than string, avoiding logging the variable in clear text, and masking the value
* in any user inputs. See OWASP for best practices.
* </p>
*/
@OAS2 @OAS3
Password,
/**
* Supports file inputs (e.g. multipart support).
*
* <p>OAS 3.x defines files differently.</p>
* <p>
* OAS 3.x does not have an explicit "file" type and instead relies on ContentType or response types.
* That's not to say a generator doesn't support files, only that there's no direct
* "file" type defined in the spec document.
* </p>
* <p>
* NOTE: The default workflow may provide an "isFile" helper or synthesize the assumptions around files in the case of OAS 3.x.
* </p>
*/
@OAS2
File,
/**
* Supports arrays of data
*/
@OAS2 @OAS3
Array,
/**
* Supports map of data
*/
@ToolingExtension
Maps,
/**
* Supports specifying the format of the array if type array is used (one of: csv, ssv, tsv, pipes).
*
* <p>
* For multi support, check {@link DataTypeFeature#CollectionFormatMulti}. OAS 3.x removes collectionFormat in favor of Style properties.
* </p>
*/
@OAS2
CollectionFormat,
/**
* Supports collection format=multi.
*
* <p>
* This is special cased because it is not as easily implemented as a delimiter as with CollectionFormat.
* OAS 3.x removes collectionFormat for style properties.
* </p>
*/
@OAS2
CollectionFormatMulti,
/**
* Supports enum properties
*/
@OAS2 @OAS3
Enum,
/**
* Supports an array of enum
*/
@ToolingExtension
ArrayOfEnum,
/**
* Supports an array of models
*/
@ToolingExtension
ArrayOfModel,
/**
* Supports an array of arrays (primitives)
*/
@ToolingExtension
ArrayOfCollectionOfPrimitives,
/**
* Supports an array of arrays (models)
*/
@ToolingExtension
ArrayOfCollectionOfModel,
/**
* Supports an array of arrays (enums)
*/
@ToolingExtension
ArrayOfCollectionOfEnum,
/**
* Supports a map of enums
*/
@ToolingExtension
MapOfEnum,
/**
* Supports a map of models
*/
@ToolingExtension
MapOfModel,
/**
* Supports a map of arrays (primitives)
*/
@ToolingExtension
MapOfCollectionOfPrimitives,
/**
* Supports a map of arrays (models)
*/
@ToolingExtension
MapOfCollectionOfModel,
/**
* Supports a map of arrays (enums)
*/
@ToolingExtension
MapOfCollectionOfEnum
}

View File

@@ -0,0 +1,42 @@
/*
* Copyright 2019 OpenAPI-Generator Contributors (https://openapi-generator.tech)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.openapitools.codegen.meta.features;
import org.openapitools.codegen.meta.features.annotations.ToolingExtension;
/**
* Defines the documentation type available in generated output.
*/
public enum DocumentationFeature {
/**
* Generated output includes a README.
*/
@ToolingExtension
Readme,
/**
* Generated output includes documentation for all generated models.
*/
@ToolingExtension
Model,
/**
* Generated output includes documentation for all generated APIs.
*/
@ToolingExtension
Api;
}

View File

@@ -0,0 +1,149 @@
/*
* Copyright 2019 OpenAPI-Generator Contributors (https://openapi-generator.tech)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.openapitools.codegen.meta.features;
import org.openapitools.codegen.meta.features.annotations.OAS2;
import org.openapitools.codegen.meta.features.annotations.OAS3;
/**
* Defines a set of globally available features. That is, support of these are often defined at the top-level of the spec, or
* defines general support of a feature (e.g. Examples, XMLStructureDefinitions).
*/
public enum GlobalFeature {
/**
* Supports specifying the host or ip of the target system. If not defined, this should fall back to the
* host/ip (and optional port) of the server which delivered the spec document.
*/
@OAS2 @OAS3
Host,
/**
* Supports providing an API prefix, appended to the host.
*
* <p>OAS 3.x supports this indirectly via servers with template variables.</p>
*/
@OAS2 @OAS3
BasePath,
/**
* Supports passing information about the target server to the client.
*
* <p>
* Information passed to generated code should be explicitly documented in a generator's README.
* </p>
*/
@OAS2 @OAS3
Info,
/**
* Supports customization of the scheme "http", "https", "ws", "wss".
*
* <p>
* If a generator only supports partial schemes, please choose the PartialSchemes option.
* </p>
*
* <p>OAS 3.x supports this indirectly via servers with template variables.</p>
*/
@OAS2 @OAS3
Schemes,
/**
* Supports fewer than all schemes supported by OpenAPI Specification.
*
* <p>
* Support should be explicitly documented in a generator's README.
* </p>
*
* <p>OAS 3.x supports this indirectly via servers with template variables.</p>
*/
@OAS2 @OAS3
PartialSchemes,
/**
* Supports a globally defined array of consumable MimeTypes.
*
* <p>Global support is undefined in OAS 3.x.</p>
*/
@OAS2
Consumes,
/**
* Supports a globally defined array of produced MimeTypes.
*
* <p>Global support is undefined in OAS 3.x.</p>
*/
@OAS2
Produces,
/**
* Exposes external documentation defined in the specification document to generated code.
*/
@OAS2 @OAS3
ExternalDocumentation,
/**
* Allows the ability to provide example input/output structures, usually in JSON format.
*/
@OAS2 @OAS3
Examples,
/**
* Differs from supporting the MimeType.XML feature, in that this option indicates whether XML structures can be defined by spec document and honored by the caller.
*/
@OAS2 @OAS3
XMLStructureDefinitions,
/**
* Supports targeting one or more servers.
*
* <p>
* That is, server is not hard-coded (although there may be a default).
* This option is valid only for "servers" without open-ended values.
* </p>
*/
@OAS3
MultiServer,
/**
* Supports targeting one or more servers, PLUS the ability to provide values for templated server parts
*/
@OAS3
ParameterizedServer,
/**
* Supports OAS 3.x "style" for parameters.
*
* <p>
* NOTE: This option is more relevant for documentation generators which support HTML stylesheets, but may be used
* to determine structural characteristics of a property (as with OAS 3.x lack of collectionFormat).
* </p>
*/
@OAS3
ParameterStyling,
/**
* Supports OAS 3.x callbacks.
*/
@OAS3
Callbacks,
/**
* Supports OAS 3.x link objects, but does *NOT* suggest generated clients auto-follow links.
*/
@OAS3
LinkObjects
}

View File

@@ -0,0 +1,77 @@
/*
* Copyright 2019 OpenAPI-Generator Contributors (https://openapi-generator.tech)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.openapitools.codegen.meta.features;
import org.openapitools.codegen.meta.features.annotations.OAS2;
import org.openapitools.codegen.meta.features.annotations.OAS3;
/**
* Defines parameters supported by endpoints in the generated code.
*/
public enum ParameterFeature {
/**
* Supports path parameters.
*/
@OAS2 @OAS3
Path,
/**
* Supports query parameters.
*/
@OAS2 @OAS3
Query,
/**
* Supports header parameters.
*/
@OAS2 @OAS3
Header,
/**
* Supports body parameters.
*
* <p>
* OAS 3.x specification supports this structurally rather than as an "in" parameter.
* </p>
*/
@OAS2
Body,
/**
* Supports form encoded parameters.
*
* OAS 3.x specification supports this structurally via content types rather than as an "in" parameter.
*/
@OAS2
FormUnencoded,
/**
* Supports multipart parameters.
*
* <p>OAS 3.x specification supports this structurally via content types rather than as an "in" parameter.</p>
*/
@OAS2
FormMultipart,
/**
* Supports Cookie parameters.
*
* <p>Not defined in OAS 2.0 and no tooling extensions currently supported for OAS 2.0 support.</p>
*/
@OAS3
Cookie
}

View File

@@ -0,0 +1,70 @@
/*
* Copyright 2019 OpenAPI-Generator Contributors (https://openapi-generator.tech)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.openapitools.codegen.meta.features;
import org.openapitools.codegen.meta.features.annotations.OAS2;
import org.openapitools.codegen.meta.features.annotations.OAS3;
/**
* Defines special circumstances handled by the generator.
*/
public enum SchemaSupportFeature {
/**
* Support of simple schemas (those which define properties directly).
*/
@OAS2 @OAS3
Simple,
/**
* Support of complex schemas (those which refer to the properties of another model).
*
* <p>In OpenAPI Specification, this indicates support of AllOf/OneOf.</p>
*/
@OAS2 @OAS3
Composite,
/**
* Support for polymorphic classes.
*
* <p>
* This suggests Composite support, but may not always be the case and is therefore separate.
* </p>
*
* <p>In OpenAPI Specification, this indicates support of AllOf with a discriminator property on the derived schema.</p>
*/
@OAS2 @OAS3
Polymorphism,
/**
* Support for a union type.
*
* <p>
* This means that a single "Type" in generated code may refer to one of any type in a set of 2 or more types.
*
* This is defined as a union as "OneOf" support is not explicitly limited to physical boundaries in OpenAPI Specification. The
* implementation of such a type is easily represented dynamically (a JSON object), but requires explicit language support and
* potentially a custom implementation (typed instances).
*
* Note that a generator may support "Unions" very loosely by returning an Object/Any/ref/interface{} type, leaving onus
* on type determination to the consumer. This does *NOT* suggest generated code implements a "Union Type".
* </p>
*
* <p>This suggests support of OneOf in OpenAPI Specification with a discriminator.</p>
*/
@OAS3
Union
}

View File

@@ -0,0 +1,77 @@
/*
* Copyright 2019 OpenAPI-Generator Contributors (https://openapi-generator.tech)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.openapitools.codegen.meta.features;
import org.openapitools.codegen.meta.features.annotations.OAS2;
import org.openapitools.codegen.meta.features.annotations.OAS3;
/**
* Defines security features supported in the generated code.
*/
public enum SecurityFeature {
/**
* Supports header-based basic http auth.
*/
@OAS2 @OAS3
BasicAuth,
/**
* Supports header-based api-key http auth.
*/
@OAS2 @OAS3
ApiKey,
/**
* Supports openid connect based http auth. Implies a requirement on openIdConnectUrl.
*/
@OAS3
OpenIDConnect,
/**
* Supports header-based bearer auth (e.g. header + bearer format).
*/
@OAS3
BearerToken,
/**
* Supports authorization via OAuth2 implicit flow.
*/
@OAS2 @OAS3
OAuth2_Implicit,
/**
* Supports authorization via OAuth2 password flow.
*/
@OAS2 @OAS3
OAuth2_Password,
/**
* Supports authorization via OAuth2 client credentials flow ("application" in OAS 2.0).
*
* <p>In OAS 2.0, this is called "application" flow.</p>
*/
@OAS2 @OAS3
OAuth2_ClientCredentials,
/**
* Supports authorization via OAuth2 flow ("accessCode" in OAS 2.0).
*
* <p>In OAS 2.0, this is called "accessCode" flow.</p>
*/
@OAS2 @OAS3
OAuth2_AuthorizationCode
}

View File

@@ -0,0 +1,50 @@
/*
* Copyright 2019 OpenAPI-Generator Contributors (https://openapi-generator.tech)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.openapitools.codegen.meta.features;
import org.openapitools.codegen.meta.features.annotations.OAS2;
import org.openapitools.codegen.meta.features.annotations.OAS3;
import org.openapitools.codegen.meta.features.annotations.ToolingExtension;
/**
* Defines wire formats explicitly defined in spec or supported by the tool.
*/
public enum WireFormatFeature {
/**
* Supports JSON transfer
*/
@OAS2 @OAS3
JSON,
/**
* Supports XML transfer
*/
@OAS2 @OAS3
XML,
/**
* Supports protocol buffer transfer
*/
@ToolingExtension
PROTOBUF,
/**
* Supports other mime types or wire formats for transfer, to be documented by generators.
*/
@OAS2 @OAS3
Custom
}

View File

@@ -0,0 +1,27 @@
/*
* Copyright 2019 OpenAPI-Generator Contributors (https://openapi-generator.tech)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.openapitools.codegen.meta.features.annotations;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
public @interface OAS2 {
}

View File

@@ -0,0 +1,27 @@
/*
* Copyright 2019 OpenAPI-Generator Contributors (https://openapi-generator.tech)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.openapitools.codegen.meta.features.annotations;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
public @interface OAS3 {
}

View File

@@ -0,0 +1,27 @@
/*
* Copyright 2019 OpenAPI-Generator Contributors (https://openapi-generator.tech)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.openapitools.codegen.meta.features.annotations;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
public @interface ToolingExtension {
}