Генератор клиентского кода Autorest rest не работает для типа ответа XML - PullRequest
1 голос
/ 23 мая 2019

Я пытаюсь использовать swagger 2.0 и https://github.com/Azure/autorest (Авторест) для генерации кода C # для точки отдыха.Они отлично работают, если тип ответа службы API application/json, но если он application/xml, то происходит сбой при десериализации ответа на объект.Я считаю, что это из-за xmlns (пространство имен не имеет объекта само по себе).Кто-нибудь пробовал использовать autorest в службе, которая отправляет медиатип приложения / xml, и имел успех?

Здесь может помочь любой пример: ошибка, которую я получаю

Unable to deserialize the response. Newtonsoft.Json: Unexpected character encountered while parsing value: <. Path '', line 0, position 0

Autorest veresion is : AutoRest code generation utility [version: 2.0.4283; node: v10.15.3]

Вот XML-файл, для которого я создаю конечную точку.https://repo1.maven.org/maven2/junit/junit/4.13-beta-1/junit-4.13-beta-1.pom

и я создал схему Swagger 2.0 из набора инструментов.

swagger: '2.0'
host: repo1.maven.org
schemes:
  - https
info:
  description: API Program description
  title: Maven Registry Client
  version: 1.0.0
basePath: /maven2/
paths:
  '/{groupPath}/{artifactId}/{version}/{pomFile}':
    get:
      description: Gets Maven package details
      summary: Gets Maven package details
      externalDocs:
        description: Maven registry API documentation
        url: 'https://mvnrepository.com/'
      operationId:  GetPackageDetails
      produces:
        - application/xml
      responses:
        '200':
          description: Success
          schema:
            "$ref": "#/definitions/Maven"
      security: []
      parameters:
        - in: path
          name: groupPath
          description: Path of the Group
          required: true
          type: string
        - in: path
          name: artifactId
          description: Artifact Id
          required: true
          type: string          
        - in: path
          name: version
          description: Version of the Package
          required: true
          type: string
        - in: path
          name: pomFile
          description: Pom File of the package file
          required: true
          type: string   
definitions:
  Maven:
    type: object
    additionalProperties: false
    properties:
      '@schemaLocation':
        type: string
        format: uri
      modelVersion:
        type: string
      groupId:
        type: string
      artifactId:
        type: string
      version:
        type: string
      name:
        type: string
      description:
        type: string
      url:
        type: string
        format: uri
      inceptionYear:
        type: string
        format: integer
      organization:
        $ref: '#/definitions/Organization'
      licenses:
        $ref: '#/definitions/Licenses'
      developers:
        $ref: '#/definitions/Developers'
      contributors:
        $ref: '#/definitions/Contributors'
      mailingLists:
        $ref: '#/definitions/MailingLists'
      prerequisites:
        $ref: '#/definitions/Prerequisites'
      scm:
        $ref: '#/definitions/SCM'
      issueManagement:
        $ref: '#/definitions/Management'
      ciManagement:
        $ref: '#/definitions/Management'
      distributionManagement:
        $ref: '#/definitions/DistributionManagement'
      properties:
        $ref: '#/definitions/MavenProperties'
      dependencies:
        $ref: '#/definitions/MavenDependencies'
      build:
        $ref: '#/definitions/MavenBuild'
      reporting:
        $ref: '#/definitions/MavenReporting'
      profiles:
        $ref: '#/definitions/Profiles'
    title: Maven
  MavenBuild:
    type: object
    additionalProperties: false
    properties:
      resources:
        $ref: '#/definitions/Resources'
      plugins:
        $ref: '#/definitions/PurplePlugins'
    title: MavenBuild
  PurplePlugins:
    type: object
    additionalProperties: false
    properties:
      plugin:
        type: array
        items:
          $ref: '#/definitions/PurplePlugin'
    title: PurplePlugins
  PurplePlugin:
    type: object
    additionalProperties: false
    properties:
      artifactId:
        type: string
      version:
        type: string
      executions:
        $ref: '#/definitions/Executions'
      groupId:
        type: string
      configuration:
        $ref: '#/definitions/PurpleConfiguration'
      dependencies:
        $ref: '#/definitions/PluginDependencies'
    title: PurplePlugin
  PurpleConfiguration:
    type: object
    additionalProperties: false
    properties:
      ignoreMissingFile:
        type: string
        format: boolean
      file:
        type: string
      outputFile:
        type: string
      regex:
        type: string
        format: boolean
      token:
        type: string
      value:
        type: string
      encoding:
        type: string
      source:
        type: string
      target:
        type: string
      testSource:
        type: string
      testTarget:
        type: string
      compilerVersion:
        type: string
      showDeprecation:
        type: string
        format: boolean
      showWarnings:
        type: string
        format: boolean
      debug:
        type: string
        format: boolean
      fork:
        type: string
        format: boolean
      compilerArgs:
        $ref: '#/definitions/PurpleCompilerArgs'
      maxmem:
        type: string
      test:
        type: string
      useSystemClassLoader:
        type: string
        format: boolean
      enableAssertions:
        type: string
        format: boolean
      stylesheetfile:
        type: string
      show:
        type: string
      author:
        type: string
        format: boolean
      version:
        type: string
        format: boolean
      detectLinks:
        type: string
        format: boolean
      linksource:
        type: string
        format: boolean
      keywords:
        type: string
        format: boolean
      use:
        type: string
        format: boolean
      windowtitle:
        type: string
      locale:
        type: string
      javadocVersion:
        type: string
      javaApiLinks:
        $ref: '#/definitions/JavaAPILinks'
      excludePackageNames:
        type: string
      verbose:
        type: string
        format: boolean
      minmemory:
        type: string
      maxmemory:
        type: string
      failOnError:
        type: string
        format: boolean
      includeDependencySources:
        type: string
        format: boolean
      dependencySourceIncludes:
        $ref: '#/definitions/DependencySourceIncludes'
      mavenExecutorId:
        type: string
      useReleaseProfile:
        type: string
        format: boolean
      arguments:
        type: string
      tagNameFormat:
        type: string
      archive:
        $ref: '#/definitions/Archive'
    title: PurpleConfiguration
  Archive:
    type: object
    additionalProperties: false
    properties:
      addMavenDescriptor:
        type: string
        format: boolean
      manifest:
        $ref: '#/definitions/Manifest'
      manifestEntries:
        $ref: '#/definitions/ManifestEntries'
    title: Archive
  Manifest:
    type: object
    additionalProperties: false
    properties:
      addDefaultImplementationEntries:
        type: string
        format: boolean
    title: Manifest
  ManifestEntries:
    type: object
    additionalProperties: false
    properties:
      Automatic-Module-Name:
        type: string
    title: ManifestEntries
  PurpleCompilerArgs:
    type: object
    additionalProperties: false
    properties:
      arg:
        type: string
    title: PurpleCompilerArgs
  DependencySourceIncludes:
    type: object
    additionalProperties: false
    properties:
      dependencySourceInclude:
        type: string
    title: DependencySourceIncludes
  JavaAPILinks:
    type: object
    additionalProperties: false
    properties:
      property:
        $ref: '#/definitions/Property'
    title: JavaAPILinks
  Property:
    type: object
    additionalProperties: false
    properties:
      name:
        type: string
      value:
        type: string
    title: Property
  PluginDependencies:
    type: object
    additionalProperties: false
    properties:
      dependency:
        $ref: '#/definitions/DependencyUnion'
    title: PluginDependencies
  DependencyElement:
    type: object
    additionalProperties: false
    properties:
      groupId:
        type: string
      artifactId:
        type: string
      version:
        type: string
      scope:
        type: string
    title: DependencyElement
  Executions:
    type: object
    additionalProperties: false
    properties:
      execution:
        $ref: '#/definitions/Execution'
    title: Executions
  Execution:
    type: object
    additionalProperties: false
    properties:
      id:
        type: string
      phase:
        type: string
      goals:
        $ref: '#/definitions/Goals'
      configuration:
        $ref: '#/definitions/ExecutionConfiguration'
    title: Execution
  ExecutionConfiguration:
    type: object
    additionalProperties: false
    properties:
      fail:
        type: string
        format: boolean
      rules:
        $ref: '#/definitions/Rules'
      signature:
        $ref: '#/definitions/DependencyElement'
    title: ExecutionConfiguration
  Rules:
    type: object
    additionalProperties: false
    properties:
      requireMavenVersion:
        $ref: '#/definitions/RequireVersion'
      requireJavaVersion:
        $ref: '#/definitions/RequireVersion'
      requireNoRepositories:
        $ref: '#/definitions/Require'
      requireReleaseDeps:
        $ref: '#/definitions/Require'
    title: Rules
  RequireVersion:
    type: object
    additionalProperties: false
    properties:
      message:
        type: string
      version:
        type: string
    title: RequireVersion
  Require:
    type: object
    additionalProperties: false
    properties:
      message:
        type: string
    title: Require
  Goals:
    type: object
    additionalProperties: false
    properties:
      goal:
        type: string
    title: Goals
  Resources:
    type: object
    additionalProperties: false
    properties:
      resource:
        type: array
        items:
          $ref: '#/definitions/Resource'
    title: Resources
  Resource:
    type: object
    additionalProperties: false
    properties:
      directory:
        type: string
      includes:
        $ref: '#/definitions/Includes'
    title: Resource
  Includes:
    type: object
    additionalProperties: false
    properties:
      include:
        type: string
    title: Includes
  Management:
    type: object
    additionalProperties: false
    properties:
      system:
        type: string
      url:
        type: string
        format: uri
    title: Management
  Contributors:
    type: object
    additionalProperties: false
    properties:
      contributor:
        $ref: '#/definitions/Contributor'
    title: Contributors
  Contributor:
    type: object
    additionalProperties: false
    properties:
      name:
        type: string
      organization:
        type: string
      email:
        type: string
      url:
        type: string
        format: uri
      roles:
        $ref: '#/definitions/Roles'
    title: Contributor
  Roles:
    type: object
    additionalProperties: false
    properties:
      role:
        type: string
    title: Roles
  MavenDependencies:
    type: object
    additionalProperties: false
    properties:
      dependency:
        type: array
        items:
          $ref: '#/definitions/DependencyElement'
    title: MavenDependencies
  Developers:
    type: object
    additionalProperties: false
    properties:
      developer:
        type: array
        items:
          $ref: '#/definitions/Developer'
    title: Developers
  Developer:
    type: object
    additionalProperties: false
    properties:
      id:
        type: string
      name:
        type: string
      email:
        type: string
    title: Developer
  DistributionManagement:
    type: object
    additionalProperties: false
    properties:
      downloadUrl:
        type: string
        format: uri
      snapshotRepository:
        $ref: '#/definitions/Repository'
      repository:
        $ref: '#/definitions/Repository'
      site:
        $ref: '#/definitions/Site'
    title: DistributionManagement
  Repository:
    type: object
    additionalProperties: false
    properties:
      id:
        type: string
      name:
        type: string
      url:
        type: string
        format: uri
    title: Repository
  Site:
    type: object
    additionalProperties: false
    properties:
      id:
        type: string
      url:
        type: string
    title: Site
  Licenses:
    type: object
    additionalProperties: false
    properties:
      license:
        $ref: '#/definitions/License'
    title: Licenses
  License:
    type: object
    additionalProperties: false
    properties:
      name:
        type: string
      url:
        type: string
        format: uri
      distribution:
        type: string
    title: License
  MailingLists:
    type: object
    additionalProperties: false
    properties:
      mailingList:
        $ref: '#/definitions/MailingList'
    title: MailingLists
  MailingList:
    type: object
    additionalProperties: false
    properties:
      name:
        type: string
      post:
        type: string
      archive:
        type: string
        format: uri
    title: MailingList
  Organization:
    type: object
    additionalProperties: false
    properties:
      name:
        type: string
      url:
        type: string
        format: uri
    title: Organization
  Prerequisites:
    type: object
    additionalProperties: false
    properties:
      maven:
        type: string
    title: Prerequisites
  Profiles:
    type: object
    additionalProperties: false
    properties:
      profile:
        type: array
        items:
          $ref: '#/definitions/Profile'
    title: Profiles
  Profile:
    type: object
    additionalProperties: false
    properties:
      id:
        type: string
      build:
        $ref: '#/definitions/ProfileBuild'
      activation:
        $ref: '#/definitions/Activation'
      reporting:
        $ref: '#/definitions/ProfileReporting'
      properties:
        $ref: '#/definitions/ProfileProperties'
    title: Profile
  Activation:
    type: object
    additionalProperties: false
    properties:
      jdk:
        type: string
    title: Activation
  ProfileBuild:
    type: object
    additionalProperties: false
    properties:
      plugins:
        $ref: '#/definitions/FluffyPlugins'
    title: ProfileBuild
  FluffyPlugins:
    type: object
    additionalProperties: false
    properties:
      plugin:
        $ref: '#/definitions/PluginUnion'
    title: FluffyPlugins
  FluffyPlugin:
    type: object
    additionalProperties: false
    properties:
      artifactId:
        type: string
      executions:
        $ref: '#/definitions/Executions'
      configuration:
        $ref: '#/definitions/FluffyConfiguration'
    title: FluffyPlugin
  TentacledPlugin:
    type: object
    additionalProperties: false
    properties:
      artifactId:
        type: string
      version:
        type: string
      executions:
        $ref: '#/definitions/Executions'
    title: TentacledPlugin
  FluffyConfiguration:
    type: object
    additionalProperties: false
    properties:
      compilerArgs:
        $ref: '#/definitions/FluffyCompilerArgs'
      additionalparam:
        type: string
    title: FluffyConfiguration
  FluffyCompilerArgs:
    type: object
    additionalProperties: false
    properties:
      arg:
        type: array
        items:
          type: string
    title: FluffyCompilerArgs
  ProfileProperties:
    type: object
    additionalProperties: false
    properties:
      jdkVersion:
        type: string
    title: ProfileProperties
  ProfileReporting:
    type: object
    additionalProperties: false
    properties:
      plugins:
        $ref: '#/definitions/TentacledPlugins'
    title: ProfileReporting
  TentacledPlugins:
    type: object
    additionalProperties: false
    properties:
      plugin:
        $ref: '#/definitions/StickyPlugin'
    title: TentacledPlugins
  StickyPlugin:
    type: object
    additionalProperties: false
    properties:
      artifactId:
        type: string
      configuration:
        $ref: '#/definitions/TentacledConfiguration'
    title: StickyPlugin
  TentacledConfiguration:
    type: object
    additionalProperties: false
    properties:
      additionalparam:
        type: string
    title: TentacledConfiguration
  MavenProperties:
    type: object
    additionalProperties: false
    properties:
      jdkVersion:
        type: string
      surefireVersion:
        type: string
      hamcrestVersion:
        type: string
      project.build.sourceEncoding:
        type: string
      arguments:
        type: string
      gpg.keyname:
        type: string
    title: MavenProperties
  MavenReporting:
    type: object
    additionalProperties: false
    properties:
      plugins:
        $ref: '#/definitions/StickyPlugins'
    title: MavenReporting
  StickyPlugins:
    type: object
    additionalProperties: false
    properties:
      plugin:
        type: array
        items:
          $ref: '#/definitions/IndigoPlugin'
    title: StickyPlugins
  IndigoPlugin:
    type: object
    additionalProperties: false
    properties:
      artifactId:
        type: string
      version:
        type: string
      configuration:
        $ref: '#/definitions/StickyConfiguration'
      reportSets:
        $ref: '#/definitions/ReportSets'
    title: IndigoPlugin
  StickyConfiguration:
    type: object
    additionalProperties: false
    properties:
      dependencyLocationsEnabled:
        type: string
        format: boolean
      destDir:
        type: string
      stylesheetfile:
        type: string
      show:
        type: string
      author:
        type: string
        format: boolean
      version:
        type: string
        format: boolean
      detectLinks:
        type: string
        format: boolean
      linksource:
        type: string
        format: boolean
      keywords:
        type: string
        format: boolean
      use:
        type: string
        format: boolean
      windowtitle:
        type: string
      encoding:
        type: string
      locale:
        type: string
      javadocVersion:
        type: string
      javaApiLinks:
        $ref: '#/definitions/JavaAPILinks'
      excludePackageNames:
        type: string
      verbose:
        type: string
        format: boolean
      minmemory:
        type: string
      maxmemory:
        type: string
      failOnError:
        type: string
        format: boolean
      includeDependencySources:
        type: string
        format: boolean
      dependencySourceIncludes:
        $ref: '#/definitions/DependencySourceIncludes'
    title: StickyConfiguration
  ReportSets:
    type: object
    additionalProperties: false
    properties:
      reportSet:
        $ref: '#/definitions/ReportSet'
    title: ReportSets
  ReportSet:
    type: object
    additionalProperties: false
    properties:
      reports:
        $ref: '#/definitions/Reports'
    title: ReportSet
  Reports:
    type: object
    additionalProperties: false
    properties:
      report:
        $ref: '#/definitions/Report'
    title: Reports
  SCM:
    type: object
    additionalProperties: false
    properties:
      connection:
        type: string
      developerConnection:
        type: string
      url:
        type: string
        format: uri
      tag:
        type: string
    title: SCM
  DependencyUnion:
    type: array
    items:
      $ref: '#/definitions/DependencyElement'
    title: DependencyUnion
  PluginUnion:
    type: array
    items:
      $ref: '#/definitions/FluffyPlugin'
    title: PluginUnion
  Report:
    type: array
    items:
      type: string
    title: Report
...