diff --git a/bin/configs/crystal.yaml b/bin/configs/crystal.yaml index db88d8bfd9b5..76cdfcd88ac6 100644 --- a/bin/configs/crystal.yaml +++ b/bin/configs/crystal.yaml @@ -6,6 +6,7 @@ additionalProperties: shardVersion: 1.0.0 moduleName: Petstore shardName: petstore + #paramsEncoder: Crest::EnumeratedFlatParamsEncoder strictSpecBehavior: false modelNameMappings: PropertyNameMapping: AnotherPropertyNameMapping diff --git a/docs/generators/crystal.md b/docs/generators/crystal.md index b9d588123329..ba481b67e4da 100644 --- a/docs/generators/crystal.md +++ b/docs/generators/crystal.md @@ -25,6 +25,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl |hideGenerationTimestamp|Hides the generation timestamp when files are generated.| |true| |legacyDiscriminatorBehavior|Set to false for generators with better support for discriminators. (Python, Java, Go, PowerShell, C# have this enabled by default).|
**true**
The mapping in the discriminator includes descendent schemas that allOf inherit from self and the discriminator mapping schemas in the OAS document.
**false**
The mapping in the discriminator includes any descendent schemas that allOf inherit from self, any oneOf schemas, any anyOf schemas, any x-discriminator-values, and the discriminator mapping schemas in the OAS document AND Codegen validates that oneOf and anyOf schemas contain the required discriminator and throws an error if the discriminator is missing.
|true| |moduleName|module name (e.g. TwitterClient| |OpenAPIClient| +|paramsEncoder|params_encoder setting (e.g. Crest::NestedParamsEncoder, Crest::EnumeratedFlatParamsEncoder, Crest::ZeroEnumeratedFlatParamsEncoder| |Crest::NestedParamsEncoder| |prependFormOrBodyParameters|Add form or body parameters to the beginning of the parameter list.| |false| |shardAuthor|shard author (only one is supported).| |null| |shardAuthorEmail|shard author email (only one is supported).| |null| diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CrystalClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CrystalClientCodegen.java index 63ee468003ba..42ed65816e85 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CrystalClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CrystalClientCodegen.java @@ -57,6 +57,7 @@ public class CrystalClientCodegen extends DefaultCodegen { @Setter protected String shardDescription = "This shard maps to a REST API"; @Setter protected String shardAuthor = ""; @Setter protected String shardAuthorEmail = ""; + @Setter protected String paramsEncoder = "Crest::NestedParamsEncoder"; protected String apiDocPath = "docs/"; protected String modelDocPath = "docs/"; protected List primitiveTypes = new ArrayList(); @@ -70,6 +71,7 @@ public class CrystalClientCodegen extends DefaultCodegen { public static final String SHARD_DESCRIPTION = "shardDescription"; public static final String SHARD_AUTHOR = "shardAuthor"; public static final String SHARD_AUTHOR_EMAIL = "shardAuthorEmail"; + public static final String PARAMS_ENCODER = "paramsEncoder"; public CrystalClientCodegen() { super(); @@ -197,8 +199,7 @@ public CrystalClientCodegen() { cliOptions.add(new CliOption(SHARD_HOMEPAGE, "shard homepage.").defaultValue("http://org.openapitools")); - cliOptions.add( - new CliOption(SHARD_DESCRIPTION, "shard description.").defaultValue("This shard maps to a REST API")); + cliOptions.add(new CliOption(SHARD_DESCRIPTION, "shard description.").defaultValue("This shard maps to a REST API")); cliOptions.add(new CliOption(SHARD_AUTHOR, "shard author (only one is supported).")); @@ -206,6 +207,10 @@ public CrystalClientCodegen() { cliOptions.add(new CliOption(CodegenConstants.HIDE_GENERATION_TIMESTAMP, CodegenConstants.HIDE_GENERATION_TIMESTAMP_DESC).defaultValue(Boolean.TRUE.toString())); + + cliOptions.add(new CliOption(PARAMS_ENCODER, + "params_encoder setting (e.g. Crest::NestedParamsEncoder, Crest::EnumeratedFlatParamsEncoder, Crest::ZeroEnumeratedFlatParamsEncoder"). + defaultValue("Crest::NestedParamsEncoder")); } @Override @@ -260,6 +265,12 @@ public void processOpts() { setShardAuthorEmail((String) additionalProperties.get(SHARD_AUTHOR_EMAIL)); } + if (additionalProperties.containsKey(PARAMS_ENCODER)) { + setParamsEncoder((String) additionalProperties.get(PARAMS_ENCODER)); + } else { + additionalProperties.put(PARAMS_ENCODER, paramsEncoder); + } + // make api and model doc path available in mustache template additionalProperties.put("apiDocPath", apiDocPath); additionalProperties.put("modelDocPath", modelDocPath); diff --git a/modules/openapi-generator/src/main/resources/crystal/api_client.mustache b/modules/openapi-generator/src/main/resources/crystal/api_client.mustache index dcfecda0b783..3eff533c447a 100644 --- a/modules/openapi-generator/src/main/resources/crystal/api_client.mustache +++ b/modules/openapi-generator/src/main/resources/crystal/api_client.mustache @@ -147,7 +147,7 @@ module {{moduleName}} form: form_or_body, logging: @config.debugging, handle_errors: false, - params_encoder: Crest::NestedParamsEncoder + params_encoder: {{{paramsEncoder}}} ) response = request.execute