Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions bin/configs/crystal.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ additionalProperties:
shardVersion: 1.0.0
moduleName: Petstore
shardName: petstore
#paramsEncoder: Crest::EnumeratedFlatParamsEncoder
strictSpecBehavior: false
modelNameMappings:
PropertyNameMapping: AnotherPropertyNameMapping
Expand Down
1 change: 1 addition & 0 deletions docs/generators/crystal.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).|<dl><dt>**true**</dt><dd>The mapping in the discriminator includes descendent schemas that allOf inherit from self and the discriminator mapping schemas in the OAS document.</dd><dt>**false**</dt><dd>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.</dd></dl>|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|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> primitiveTypes = new ArrayList<String>();
Expand All @@ -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();
Expand Down Expand Up @@ -197,15 +199,18 @@ 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)."));

cliOptions.add(new CliOption(SHARD_AUTHOR_EMAIL, "shard author email (only one is supported)."));

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
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading