Как изменить по умолчанию «Тип содержимого ответа» для Swagger на «application / json»? - PullRequest
0 голосов
/ 19 марта 2020

Версия SAP Commerce Cloud: 1905.9

В настоящее время по умолчанию «Тип содержимого ответа» для Swagger имеет 2 значения: «application / xml» и «application / json». По умолчанию выбрано «application / xml». Есть ли способ изменить выбор по умолчанию на «application / json»?

Пример кода ванили выглядит следующим образом:

@ApiOperation(hidden = true, value = "Updates the total amount of a specific product", notes = "Updates the total amount of a specific product in the cart based on the entryNumber.")
@RequestMappingOverride(priorityProperty = "b2bocc.CartResource.updateCartEntry.priority")
@RequestMapping(value = "/{cartId}/entries/{entryNumber}", method = RequestMethod.PUT)
@ResponseBody
@ApiBaseSiteIdUserIdAndCartIdParam
public CartModificationWsDTO updateCartEntry(@ApiParam(value = "Base site identifier.") @PathVariable final String baseSiteId,
        @ApiParam(value = "The id of the entry in the cart.") @PathVariable final int entryNumber,
        @ApiParam(value = "New quantity for this entry.") @RequestParam(required = true) final Long quantity,
        @ApiParam(value = "Response configuration. This is the list of fields that should be returned in the response body.", allowableValues = "BASIC, DEFAULT, FULL") @RequestParam(required = false, defaultValue = FieldSetLevelHelper.DEFAULT_LEVEL) final String fields)
{

    return updateCartEntry(baseSiteId, null, entryNumber, quantity, fields);
}

1 Ответ

0 голосов
/ 23 марта 2020

Вы можете переключать порядок преобразователей в пружина mvc - сервлет. xml

    <mvc:annotation-driven>
        <mvc:message-converters>
            <ref bean="jsonHttpMessageConverter"/>
            <ref bean="xmlHttpMessageConverter"/>
<!--            <ref bean="customJsonHttpMessageConverter" /> -->
<!--            <ref bean="customXmlHttpMessageConverter" /> -->
        </mvc:message-converters>
    </mvc:annotation-driven>    
...