function getProperties()

in compiler/src/steps/validate-rest-spec.ts [172:214]


  function getProperties (definition: model.Request | model.Interface): { path: model.Property[], query: model.Property[], body: Body } {
    const path: model.Property[] = []
    const query: model.Property[] = []
    let body: Body = Body.noBody

    if (definition.kind === 'request') {
      if (definition.path.length > 0) {
        path.push(...definition.path)
      }

      if (definition.query.length > 0) {
        query.push(...definition.query)
      }

      if (definition.body.kind !== 'no_body') {
        body = Body.yesBody
      }

      if (definition.attachedBehaviors != null) {
        for (const attachedBehavior of definition.attachedBehaviors) {
          const type_ = getDefinition({
            namespace: '_spec_utils',
            name: attachedBehavior
          })
          if (
            type_.kind === 'interface' &&
            // allowing CommonQueryParameters too generates many errors
            attachedBehavior === 'CommonCatQueryParameters'
          ) {
            for (const prop of type_.properties) {
              query.push(prop)
            }
          }
        }
      }
    } else {
      if (definition.properties.length > 0) {
        query.push(...definition.properties)
      }
    }

    return { path, query, body }
  }