if (!bodyField.getType().isMessage() || bodyField.getType().isRepeated() || !bodyField.getType().getWellKnownType().allowedAsHttpRequestResponse()) {} bodyFields.add(bodyField); bound.add(bodyField);
if (!bodyField.getType().isMessage() || bodyField.getType().isRepeated() || !bodyField.getType().getWellKnownType().allowedAsHttpRequestResponse()) {} bodyFields.add(bodyField); bound.add(bodyField);
private void checkResponseObject(Method method, MethodKind kind) { if (kind != MethodKind.NONE) { WellKnownType wkt = TypeRef.of(method.getOutputMessage()).getWellKnownType(); if (!wkt.allowedAsHttpRequestResponse()) { error( ResolvedLocation.create(method.getLocation()), "type '%s' is not allowed as a response because it does not render as " + "a JSON object.", method.getOutputMessage().getFullName()); } } }
private void checkResponseObject(Method method, MethodKind kind) { if (kind != MethodKind.NONE) { WellKnownType wkt = TypeRef.of(method.getOutputMessage()).getWellKnownType(); if (!wkt.allowedAsHttpRequestResponse()) { error( ResolvedLocation.create(method.getLocation()), "type '%s' is not allowed as a response because it does not render as " + "a JSON object.", method.getOutputMessage().getFullName()); } } }
private void checkBodyConstraints(HttpAttribute binding, Method method) { if (binding.getBody() != null && !binding.bodyCapturesUnboundFields()) { if (!FieldSelector.hasSinglePathElement(binding.getBody())) { error( ResolvedLocation.create(method.getLocation()), "body field path '%s' should not reference sub messages.", binding.getBody()); } else { // There should be just one body as body is not unbounded. if (binding.getBodySelectors() != null && binding.getBodySelectors().size() == 1) { FieldSelector bodyField = Iterables.getOnlyElement(binding.getBodySelectors()); if (bodyField != null) { WellKnownType wkt = bodyField.getType().getWellKnownType(); if (!bodyField.getType().isMessage() || bodyField.getType().isRepeated() || !wkt.allowedAsHttpRequestResponse()) { error( ResolvedLocation.create(method.getLocation()), "body field path '%s' must be a non-repeated message.", bodyField); } } } } } }
private void checkBodyConstraints(HttpAttribute binding, Method method) { if (binding.getBody() != null && !binding.bodyCapturesUnboundFields()) { if (!FieldSelector.hasSinglePathElement(binding.getBody())) { error( ResolvedLocation.create(method.getLocation()), "body field path '%s' should not reference sub messages.", binding.getBody()); } else { // There should be just one body as body is not unbounded. if (binding.getBodySelectors() != null && binding.getBodySelectors().size() == 1) { FieldSelector bodyField = Iterables.getOnlyElement(binding.getBodySelectors()); if (bodyField != null) { WellKnownType wkt = bodyField.getType().getWellKnownType(); if (!bodyField.getType().isMessage() || bodyField.getType().isRepeated() || !wkt.allowedAsHttpRequestResponse()) { error( ResolvedLocation.create(method.getLocation()), "body field path '%s' must be a non-repeated message.", bodyField); } } } } } }
TypeRef type = field.getType(); WellKnownType wkt = type.getWellKnownType(); if (type.isMap()) { error(
TypeRef type = field.getType(); WellKnownType wkt = type.getWellKnownType(); if (type.isMap()) { error(
/** Checks context conditions for selectors bound to the HTTP path. */ private void checkPathParameterConditions(Method method, FieldSelector selector) { TypeRef type = selector.getType(); WellKnownType wkt = type.getWellKnownType(); if (type.isMap()) { error( ResolvedLocation.create(method.getLocation()), "map field not allowed: reached via '%s' on message '%s'.", selector.toString(), getInputMessageName(method)); } else if (type.isRepeated()) { error( ResolvedLocation.create(method.getLocation()), "repeated field not allowed: reached via '%s' on message '%s'.", selector, getInputMessageName(method)); } else if (type.isMessage() && !wkt.allowedAsPathParameter()) { error( ResolvedLocation.create(method.getLocation()), "message field not allowed: reached via '%s' on message '%s'.", selector, getInputMessageName(method)); } }
/** Checks context conditions for selectors bound to the HTTP path. */ private void checkPathParameterConditions(Method method, FieldSelector selector) { TypeRef type = selector.getType(); WellKnownType wkt = type.getWellKnownType(); if (type.isMap()) { error( ResolvedLocation.create(method.getLocation()), "map field not allowed: reached via '%s' on message '%s'.", selector.toString(), getInputMessageName(method)); } else if (type.isRepeated()) { error( ResolvedLocation.create(method.getLocation()), "repeated field not allowed: reached via '%s' on message '%s'.", selector, getInputMessageName(method)); } else if (type.isMessage() && !wkt.allowedAsPathParameter()) { error( ResolvedLocation.create(method.getLocation()), "message field not allowed: reached via '%s' on message '%s'.", selector, getInputMessageName(method)); } }