[Python] fix security features listed in documentation (#15755)

This commit is contained in:
Tiffany Marrel 2023-06-06 04:49:01 +02:00 committed by GitHub
parent b5d766de4b
commit d7226a6813
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 22 additions and 13 deletions

View File

@ -218,11 +218,11 @@ These options may be applied as additional-properties (cli) or configOptions (pl
| ---- | --------- | ---------- | | ---- | --------- | ---------- |
|BasicAuth|✓|OAS2,OAS3 |BasicAuth|✓|OAS2,OAS3
|ApiKey|✓|OAS2,OAS3 |ApiKey|✓|OAS2,OAS3
|OpenIDConnect||OAS3 |OpenIDConnect||OAS3
|BearerToken|✓|OAS3 |BearerToken|✓|OAS3
|OAuth2_Implicit|✓|OAS2,OAS3 |OAuth2_Implicit|✓|OAS2,OAS3
|OAuth2_Password|✓|OAS2,OAS3 |OAuth2_Password|✓|OAS2,OAS3
|OAuth2_ClientCredentials||OAS2,OAS3 |OAuth2_ClientCredentials||OAS2,OAS3
|OAuth2_AuthorizationCode|✓|OAS2,OAS3 |OAuth2_AuthorizationCode|✓|OAS2,OAS3
|SignatureAuth|✗|OAS3 |SignatureAuth|✗|OAS3

View File

@ -223,12 +223,12 @@ These options may be applied as additional-properties (cli) or configOptions (pl
| ---- | --------- | ---------- | | ---- | --------- | ---------- |
|BasicAuth|✓|OAS2,OAS3 |BasicAuth|✓|OAS2,OAS3
|ApiKey|✓|OAS2,OAS3 |ApiKey|✓|OAS2,OAS3
|OpenIDConnect||OAS3 |OpenIDConnect||OAS3
|BearerToken|✓|OAS3 |BearerToken|✓|OAS3
|OAuth2_Implicit|✓|OAS2,OAS3 |OAuth2_Implicit|✓|OAS2,OAS3
|OAuth2_Password||OAS2,OAS3 |OAuth2_Password||OAS2,OAS3
|OAuth2_ClientCredentials||OAS2,OAS3 |OAuth2_ClientCredentials||OAS2,OAS3
|OAuth2_AuthorizationCode||OAS2,OAS3 |OAuth2_AuthorizationCode||OAS2,OAS3
|SignatureAuth|✗|OAS3 |SignatureAuth|✗|OAS3
### Wire Format Feature ### Wire Format Feature

View File

@ -220,7 +220,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|OAuth2_Password|✗|OAS2,OAS3 |OAuth2_Password|✗|OAS2,OAS3
|OAuth2_ClientCredentials|✗|OAS2,OAS3 |OAuth2_ClientCredentials|✗|OAS2,OAS3
|OAuth2_AuthorizationCode|✗|OAS2,OAS3 |OAuth2_AuthorizationCode|✗|OAS2,OAS3
|SignatureAuth||OAS3 |SignatureAuth||OAS3
### Wire Format Feature ### Wire Format Feature
| Name | Supported | Defined By | | Name | Supported | Defined By |

View File

@ -24,6 +24,7 @@ import io.swagger.v3.oas.models.parameters.Parameter;
import org.apache.commons.io.FilenameUtils; import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.openapitools.codegen.*; import org.openapitools.codegen.*;
import org.openapitools.codegen.meta.features.SecurityFeature;
import org.openapitools.codegen.utils.ModelUtils; import org.openapitools.codegen.utils.ModelUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -49,6 +50,13 @@ public abstract class AbstractPythonCodegen extends DefaultCodegen implements Co
public AbstractPythonCodegen() { public AbstractPythonCodegen() {
super(); super();
modifyFeatureSet(features -> features.securityFeatures(EnumSet.of(
SecurityFeature.BasicAuth,
SecurityFeature.BearerToken,
SecurityFeature.ApiKey,
SecurityFeature.OAuth2_Implicit
)));
// from https://docs.python.org/3/reference/lexical_analysis.html#keywords // from https://docs.python.org/3/reference/lexical_analysis.html#keywords
setReservedWordsLowerCase( setReservedWordsLowerCase(
Arrays.asList( Arrays.asList(

View File

@ -78,12 +78,7 @@ public class PythonClientCodegen extends AbstractPythonCodegen implements Codege
modifyFeatureSet(features -> features modifyFeatureSet(features -> features
.includeDocumentationFeatures(DocumentationFeature.Readme) .includeDocumentationFeatures(DocumentationFeature.Readme)
.wireFormatFeatures(EnumSet.of(WireFormatFeature.JSON, WireFormatFeature.XML, WireFormatFeature.Custom)) .wireFormatFeatures(EnumSet.of(WireFormatFeature.JSON, WireFormatFeature.XML, WireFormatFeature.Custom))
.securityFeatures(EnumSet.of( .includeSecurityFeatures(SecurityFeature.SignatureAuth)
SecurityFeature.BasicAuth,
SecurityFeature.BearerToken,
SecurityFeature.ApiKey,
SecurityFeature.OAuth2_Implicit
))
.excludeGlobalFeatures( .excludeGlobalFeatures(
GlobalFeature.XMLStructureDefinitions, GlobalFeature.XMLStructureDefinitions,
GlobalFeature.Callbacks, GlobalFeature.Callbacks,

View File

@ -28,6 +28,7 @@ import org.apache.commons.lang3.StringUtils;
import org.openapitools.codegen.*; import org.openapitools.codegen.*;
import org.openapitools.codegen.meta.GeneratorMetadata; import org.openapitools.codegen.meta.GeneratorMetadata;
import org.openapitools.codegen.meta.Stability; import org.openapitools.codegen.meta.Stability;
import org.openapitools.codegen.meta.features.SecurityFeature;
import org.openapitools.codegen.model.ModelMap; import org.openapitools.codegen.model.ModelMap;
import org.openapitools.codegen.model.ModelsMap; import org.openapitools.codegen.model.ModelsMap;
import org.openapitools.codegen.model.OperationMap; import org.openapitools.codegen.model.OperationMap;
@ -88,6 +89,11 @@ public class PythonFastAPIServerCodegen extends AbstractPythonCodegen {
public PythonFastAPIServerCodegen() { public PythonFastAPIServerCodegen() {
super(); super();
modifyFeatureSet(features -> features.includeSecurityFeatures(
SecurityFeature.OAuth2_AuthorizationCode,
SecurityFeature.OAuth2_Password
));
generatorMetadata = GeneratorMetadata.newBuilder(generatorMetadata) generatorMetadata = GeneratorMetadata.newBuilder(generatorMetadata)
.stability(Stability.BETA) .stability(Stability.BETA)
.build(); .build();