use {{{mediaType}} instead of {{mediaType}} (#7073)

This commit is contained in:
William Cheng 2017-11-29 16:17:51 +08:00 committed by GitHub
parent d2a2292d20
commit 5994a2fb2d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 19 additions and 19 deletions

View File

@ -89,11 +89,11 @@ public class {{classname}} {
{{/hasMore}}{{/formParams}}{{/hasFormParams}} {{/hasMore}}{{/formParams}}{{/hasFormParams}}
final String[] {{localVariablePrefix}}accepts = { {{#hasProduces}} final String[] {{localVariablePrefix}}accepts = { {{#hasProduces}}
{{#produces}}"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/produces}} {{#produces}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/produces}}
{{/hasProduces}}}; {{/hasProduces}}};
final List<MediaType> {{localVariablePrefix}}accept = {{localVariablePrefix}}apiClient.selectHeaderAccept({{localVariablePrefix}}accepts); final List<MediaType> {{localVariablePrefix}}accept = {{localVariablePrefix}}apiClient.selectHeaderAccept({{localVariablePrefix}}accepts);
final String[] {{localVariablePrefix}}contentTypes = { {{#hasConsumes}} final String[] {{localVariablePrefix}}contentTypes = { {{#hasConsumes}}
{{#consumes}}"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/consumes}} {{#consumes}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/consumes}}
{{/hasConsumes}}}; {{/hasConsumes}}};
final MediaType {{localVariablePrefix}}contentType = {{localVariablePrefix}}apiClient.selectHeaderContentType({{localVariablePrefix}}contentTypes); final MediaType {{localVariablePrefix}}contentType = {{localVariablePrefix}}apiClient.selectHeaderContentType({{localVariablePrefix}}contentTypes);

View File

@ -50,7 +50,7 @@ public interface {{classname}} {
{{#prioritizedContentTypes}} {{#prioritizedContentTypes}}
{{#-first}} {{#-first}}
@Headers({ @Headers({
"Content-Type:{{mediaType}}" "Content-Type:{{{mediaType}}}"
}) })
{{/-first}} {{/-first}}
{{/prioritizedContentTypes}} {{/prioritizedContentTypes}}

View File

@ -42,7 +42,7 @@ public interface {{classname}} {
{{#prioritizedContentTypes}} {{#prioritizedContentTypes}}
{{#-first}} {{#-first}}
@Headers({ @Headers({
"Content-Type:{{mediaType}}" "Content-Type:{{{mediaType}}}"
}) })
{{/-first}} {{/-first}}
{{/prioritizedContentTypes}} {{/prioritizedContentTypes}}

View File

@ -42,7 +42,7 @@ public interface {{classname}} {
{{#prioritizedContentTypes}} {{#prioritizedContentTypes}}
{{#-first}} {{#-first}}
@Headers({ @Headers({
"Content-Type:{{mediaType}}" "Content-Type:{{{mediaType}}}"
}) })
{{/-first}} {{/-first}}
{{/prioritizedContentTypes}} {{/prioritizedContentTypes}}

View File

@ -41,8 +41,8 @@ public class {{classname}} {
@{{httpMethod}} @{{httpMethod}}
{{#subresourceOperation}}@Path("{{{path}}}"){{/subresourceOperation}} {{#subresourceOperation}}@Path("{{{path}}}"){{/subresourceOperation}}
{{#hasConsumes}}@Consumes({ {{#consumes}}"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/consumes}} }){{/hasConsumes}} {{#hasConsumes}}@Consumes({ {{#consumes}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/consumes}} }){{/hasConsumes}}
{{#hasProduces}}@Produces({ {{#produces}}"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }){{/hasProduces}} {{#hasProduces}}@Produces({ {{#produces}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }){{/hasProduces}}
@ApiOperation(value = "{{{summary}}}", notes = "{{{notes}}}", response = {{{returnBaseType}}}.class{{#returnContainer}}, responseContainer = "{{{returnContainer}}}"{{/returnContainer}}{{#hasAuthMethods}}, authorizations = { @ApiOperation(value = "{{{summary}}}", notes = "{{{notes}}}", response = {{{returnBaseType}}}.class{{#returnContainer}}, responseContainer = "{{{returnContainer}}}"{{/returnContainer}}{{#hasAuthMethods}}, authorizations = {
{{#authMethods}}@Authorization(value = "{{name}}"{{#isOAuth}}, scopes = { {{#authMethods}}@Authorization(value = "{{name}}"{{#isOAuth}}, scopes = {
{{#scopes}}@AuthorizationScope(scope = "{{scope}}", description = "{{description}}"){{#hasMore}}, {{#scopes}}@AuthorizationScope(scope = "{{scope}}", description = "{{description}}"){{#hasMore}},

View File

@ -88,13 +88,13 @@ public class {{classname}} {
{{/headerParams}} {{/headerParams}}
}{{/hasHeaderParams}}{{^hasHeaderParams}}(){{/hasHeaderParams}}, }{{/hasHeaderParams}}{{^hasHeaderParams}}(){{/hasHeaderParams}},
{{#hasProduces}} {{#hasProduces}}
new List<String>{ {{#produces}}'{{mediaType}}'{{#hasMore}}, {{/hasMore}}{{/produces}} }, new List<String>{ {{#produces}}'{{{mediaType}}}'{{#hasMore}}, {{/hasMore}}{{/produces}} },
{{/hasProduces}} {{/hasProduces}}
{{^hasProduces}} {{^hasProduces}}
new List<String>(), new List<String>(),
{{/hasProduces}} {{/hasProduces}}
{{#hasConsumes}} {{#hasConsumes}}
new List<String>{ {{#consumes}}'{{mediaType}}'{{#hasMore}}, {{/hasMore}}{{/consumes}} }, new List<String>{ {{#consumes}}'{{{mediaType}}}'{{#hasMore}}, {{/hasMore}}{{/consumes}} },
{{/hasConsumes}} {{/hasConsumes}}
{{^hasConsumes}} {{^hasConsumes}}
new List<String>(), new List<String>(),

View File

@ -706,7 +706,7 @@ print_{{operationId}}_help() {
{{/allParams}} {{/allParams}}
{{#allParams}} {{#allParams}}
{{#isBodyParam}} {{#isBodyParam}}
echo -e " * ${GREEN}body${OFF} ${BLUE}[{{#consumes}}{{mediaType}}{{#hasMore}},{{/hasMore}}{{/consumes}}]${OFF}{{#required}} ${RED}(required)${OFF}{{/required}}${OFF} - {{{description}}}" | paste -sd' ' | fold -sw 80 | sed '2,$s/^/ /' echo -e " * ${GREEN}body${OFF} ${BLUE}[{{#consumes}}{{{mediaType}}}{{#hasMore}},{{/hasMore}}{{/consumes}}]${OFF}{{#required}} ${RED}(required)${OFF}{{/required}}${OFF} - {{{description}}}" | paste -sd' ' | fold -sw 80 | sed '2,$s/^/ /'
echo -e "" echo -e ""
{{#vendorExtensions}} {{#vendorExtensions}}
{{#x-codegen-body-example}} {{#x-codegen-body-example}}
@ -791,7 +791,7 @@ call_{{operationId}}() {
{{#-first}} {{#-first}}
{{^hasMore}} {{^hasMore}}
if [[ -z $header_content_type ]]; then if [[ -z $header_content_type ]]; then
header_content_type="{{mediaType}}" header_content_type="{{{mediaType}}}"
fi fi
{{/hasMore}} {{/hasMore}}
{{/-first}} {{/-first}}
@ -805,7 +805,7 @@ call_{{operationId}}() {
echo "ERROR: Request's content-type not specified!!!" echo "ERROR: Request's content-type not specified!!!"
echo "This operation expects content-type in one of the following formats:" echo "This operation expects content-type in one of the following formats:"
{{#consumes}} {{#consumes}}
echo -e "\\t- {{mediaType}}" echo -e "\\t- {{{mediaType}}}"
{{/consumes}} {{/consumes}}
echo "" echo ""
echo "Use '--content-type' to set proper content type" echo "Use '--content-type' to set proper content type"

View File

@ -48,7 +48,7 @@ pplx::task<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/r
std::unordered_set<utility::string_t> responseHttpContentTypes; std::unordered_set<utility::string_t> responseHttpContentTypes;
{{#produces}} {{#produces}}
responseHttpContentTypes.insert( utility::conversions::to_string_t("{{mediaType}}") ); responseHttpContentTypes.insert( utility::conversions::to_string_t("{{{mediaType}}}") );
{{/produces}} {{/produces}}
utility::string_t responseHttpContentType; utility::string_t responseHttpContentType;
@ -98,7 +98,7 @@ pplx::task<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/r
std::unordered_set<utility::string_t> consumeHttpContentTypes; std::unordered_set<utility::string_t> consumeHttpContentTypes;
{{#consumes}} {{#consumes}}
consumeHttpContentTypes.insert( utility::conversions::to_string_t("{{mediaType}}") ); consumeHttpContentTypes.insert( utility::conversions::to_string_t("{{{mediaType}}}") );
{{/consumes}} {{/consumes}}
{{#allParams}} {{#allParams}}

View File

@ -58,7 +58,7 @@ class {{controllerName}} extends Controller
{ {
{{#bodyParams}} {{#bodyParams}}
// Make sure that the client is providing something that we can consume // Make sure that the client is providing something that we can consume
$consumes = [{{#consumes}}'{{mediaType}}'{{#hasMore}}, {{/hasMore}}{{/consumes}}]; $consumes = [{{#consumes}}'{{{mediaType}}}'{{#hasMore}}, {{/hasMore}}{{/consumes}}];
$inputFormat = $request->headers->has('Content-Type')?$request->headers->get('Content-Type'):$consumes[0]; $inputFormat = $request->headers->has('Content-Type')?$request->headers->get('Content-Type'):$consumes[0];
if (!in_array($inputFormat, $consumes)) { if (!in_array($inputFormat, $consumes)) {
// We can't consume the content that the client is sending us // We can't consume the content that the client is sending us
@ -67,7 +67,7 @@ class {{controllerName}} extends Controller
{{/bodyParams}} {{/bodyParams}}
// Figure out what data format to return to the client // Figure out what data format to return to the client
$produces = [{{#produces}}'{{mediaType}}'{{#hasMore}}, {{/hasMore}}{{/produces}}]; $produces = [{{#produces}}'{{{mediaType}}}'{{#hasMore}}, {{/hasMore}}{{/produces}}];
// Figure out what the client accepts // Figure out what the client accepts
$clientAccepts = $request->headers->has('Accept')?$request->headers->get('Accept'):'*/*'; $clientAccepts = $request->headers->has('Accept')?$request->headers->get('Accept'):'*/*';
$responseFormat = $this->getOutputFormat($clientAccepts, $produces); $responseFormat = $this->getOutputFormat($clientAccepts, $produces);

View File

@ -169,7 +169,7 @@ static bool {{nickname}}Helper(char * accessToken,
headerList = curl_slist_append(headerList, accessHeader.c_str()); headerList = curl_slist_append(headerList, accessHeader.c_str());
{{#hasConsumes}} {{#hasConsumes}}
{{#consumes}} {{#consumes}}
headerList = curl_slist_append(headerList, "Content-Type: {{mediaType}}"); headerList = curl_slist_append(headerList, "Content-Type: {{{mediaType}}}");
{{/consumes}} {{/consumes}}
{{/hasConsumes}} {{/hasConsumes}}
{{^hasConsumes}} {{^hasConsumes}}

View File

@ -29,7 +29,7 @@ class {{classname}} implements {{interfacesToImplement}}
{{#bodyParam}} {{#bodyParam}}
{{#consumes}} {{#consumes}}
* TODO check if consumer is valid, if it has correct priority and if it can be moved to class annotation * TODO check if consumer is valid, if it has correct priority and if it can be moved to class annotation
* @PHA\Consumer(name=PHConsumer\Json::class, mediaType="{{mediaType}}") * @PHA\Consumer(name=PHConsumer\Json::class, mediaType="{{{mediaType}}}")
{{/consumes}} {{/consumes}}
{{^isPrimitiveType}} {{^isPrimitiveType}}
* @PHA\Attribute(name=PHAttribute\Transfer::class, options={"type":{{dataType}}::class,"objectAttr":"{{paramName}}"}) * @PHA\Attribute(name=PHAttribute\Transfer::class, options={"type":{{dataType}}::class,"objectAttr":"{{paramName}}"})
@ -37,7 +37,7 @@ class {{classname}} implements {{interfacesToImplement}}
{{/bodyParam}} {{/bodyParam}}
{{#produces}} {{#produces}}
* TODO check if producer is valid, if it has correct priority and if it can be moved to class annotation * TODO check if producer is valid, if it has correct priority and if it can be moved to class annotation
* @PHA\Producer(name=PHProducer\Transfer::class, mediaType="{{mediaType}}") * @PHA\Producer(name=PHProducer\Transfer::class, mediaType="{{{mediaType}}}")
{{/produces}} {{/produces}}
* @param ServerRequestInterface $request * @param ServerRequestInterface $request
* *