Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

cannot deserialize from Object value (Grallvm native executable)

未关闭
#2,147 4 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
35/100
Issue 类型
缺陷
描述清晰度
需要澄清
活跃度
停滞
技术栈
java
领域
api

调研方向

复现解析 books.yaml 的原生可执行文件,然后从 OpenAPIParser.readLocation 经过 SwaggerConverter.convert 跟踪故障,直到 ArraySchema 反序列化。将原生结果与常规 Java 解析器的结果进行比较,并确定需要什么才能让原生解析器在不抛出所报告异常的情况下返回已填充的 OpenAPI 对象。

由索引模型根据 Issue 内容生成。

描述

Using plain java graalvm native executables cause multiple issues. The parser mostly returns empty OpenAPI objects without any error. Only on one file I can receive an error. I tried to initialise swagger models at run time, but this did not help --initialize-at-run-time=io.swagger.v3.oas.models
It would be really cool to know how to use the swagger parser on plain native java.

[ERROR] Failed to parse OpenAPI file [books.yaml]: Cannot construct instance of `io.swagger.v3.oas.models.media.ArraySchema`: cannot deserialize from Object value (no delegate- or property-based Creator): this appears to be a native image, in which case you may need to configure reflection for the class that is to be deserialized
 at [Source: UNKNOWN; byte offset: #UNKNOWN]
java.lang.IllegalArgumentException: Cannot construct instance of `io.swagger.v3.oas.models.media.ArraySchema`: cannot deserialize from Object value (no delegate- or property-based Creator): this appears to be a native image, in which case you may need to configure reflection for the class that is to be deserialized
 at [Source: UNKNOWN; byte offset: #UNKNOWN]
        at com.fasterxml.jackson.databind.ObjectMapper._convert(ObjectMapper.java:4618)
        at com.fasterxml.jackson.databind.ObjectMapper.convertValue(ObjectMapper.java:4549)
        at io.swagger.v3.parser.converter.SwaggerConverter.convert(SwaggerConverter.java:1188)
        at io.swagger.v3.parser.converter.SwaggerConverter.convert(SwaggerConverter.java:865)
        at io.swagger.v3.parser.converter.SwaggerConverter.convert(SwaggerConverter.java:635)
        at io.swagger.v3.parser.converter.SwaggerConverter.convert(SwaggerConverter.java:531)
        at io.swagger.v3.parser.converter.SwaggerConverter.convert(SwaggerConverter.java:250)
        at io.swagger.v3.parser.converter.SwaggerConverter.readResult(SwaggerConverter.java:104)
        at io.swagger.v3.parser.converter.SwaggerConverter.readLocation(SwaggerConverter.java:85)
        at io.swagger.parser.OpenAPIParser.readLocation(OpenAPIParser.java:16)
        at java.base@22/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:212)
        at java.base@22/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:194)
        at java.base@22/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:194)
        at java.base@22/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:194)
        at java.base@22/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:194)
        at java.base@22/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:212)
        at java.base@22/java.util.Iterator.forEachRemaining(Iterator.java:133)
        at java.base@22/java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1939)
        at java.base@22/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:556)
        at java.base@22/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:546)
        at java.base@22/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:151)
        at java.base@22/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:174)
        at java.base@22/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:265)
        at java.base@22/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:611)
Caused by: com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot construct instance of `io.swagger.v3.oas.models.media.ArraySchema`: cannot deserialize from Object value (no delegate- or property-based Creator): this appears to be a native image, in which case you may need to configure reflection for the class that is to be deserialized
 at [Source: UNKNOWN; byte offset: #UNKNOWN]
        at com.fasterxml.jackson.databind.DeserializationContext.reportBadDefinition(DeserializationContext.java:1887)
        at com.fasterxml.jackson.databind.DatabindContext.reportBadDefinition(DatabindContext.java:414)
        at com.fasterxml.jackson.databind.DeserializationContext.handleMissingInstantiator(DeserializationContext.java:1370)
        at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.deserializeFromObjectUsingNonDefault(BeanDeserializerBase.java:1505)
        at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:348)
        at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:185)
        at com.fasterxml.jackson.databind.ObjectMapper._convert(ObjectMapper.java:4613)
swagger: "2.0"
info:
  version: "1.0.0"
  title: "Books API"
  description: "API to manage books, authors, and their relationships."
  termsOfService: "https://api.books.example.com/terms"
  contact:
    name: "API Support"
    url: "https://api.books.example.com/support"
    email: "[email protected]"
  license:
    name: "MIT"
    url: "https://opensource.org/licenses/MIT"
host: "api.books.example.com"
basePath: "/v1"
schemes:
  - https
tags:
  - name: "Books"
    description: "Operations related to books"
  - name: "Authors"
    description: "Operations related to authors"
  - name: "Management"
    description: "Administrative operations"
paths:
  /books:
    get:
      tags:
        - "Books"
      summary: "Retrieve all books"
      description: "Returns a list of all books available in the system."
      responses:
        200:
          description: "A list of books"
          schema:
            type: "array"
            items:
              $ref: "#/definitions/Book"
    post:
      tags:
        - "Books"
      summary: "Add a new book"
      description: "Adds a new book to the library."
      parameters:
        - in: "body"
          name: "body"
          required: true
          schema:
            $ref: "#/definitions/Book"
      responses:
        201:
          description: "Book created successfully"
  /books/{id}:
    get:
      tags:
        - "Books"
      summary: "Retrieve a specific book"
      description: "Fetch details of a book by its unique ID."
      parameters:
        - name: "id"
          in: "path"
          required: true
          type: "string"
      responses:
        200:
          description: "Book details retrieved"
          schema:
            $ref: "#/definitions/Book"
        404:
          description: "Book not found"
    put:
      tags:
        - "Books"
      summary: "Update a book"
      description: "Updates information for a specific book."
      parameters:
        - name: "id"
          in: "path"
          required: true
          type: "string"
        - in: "body"
          name: "body"
          required: true
          schema:
            $ref: "#/definitions/Book"
      responses:
        200:
          description: "Book updated successfully"
    delete:
      tags:
        - "Books"
      summary: "Delete a book"
      description: "Deletes a specific book by its ID."
      parameters:
        - name: "id"
          in: "path"
          required: true
          type: "string"
      responses:
        204:
          description: "Book deleted successfully"
  /authors:
    get:
      tags:
        - "Authors"
      summary: "Retrieve all authors"
      description: "Fetch a list of all authors."
      responses:
        200:
          description: "A list of authors"
          schema:
            type: "array"
            items:
              $ref: "#/definitions/Author"
    post:
      tags:
        - "Authors"
      summary: "Add a new author"
      description: "Adds a new author to the system."
      parameters:
        - in: "body"
          name: "body"
          required: true
          schema:
            $ref: "#/definitions/Author"
      responses:
        201:
          description: "Author added successfully"
definitions:
  Book:
    type: "object"
    required:
      - id
      - title
    properties:
      id:
        type: "string"
      title:
        type: "string"
      author:
        type: "string"
      publishedDate:
        type: "string"
        format: "date"
      genre:
        type: "string"
        description: "Genre of the book"
  Author:
    type: "object"
    required:
      - id
      - name
    properties:
      id:
        type: "string"
      name:
        type: "string"
      biography:
        type: "string"
        description: "A brief biography of the author"
      birthDate:
        type: "string"
        format: "date"
        description: "Author's date of birth"
securityDefinitions:
  api_key:
    type: "apiKey"
    name: "X-API-KEY"
    in: "header"
externalDocs:
  description: "Find more info here"
  url: "https://api.books.example.com/docs"

主要语言
Java
星标
868
派生
560
PR 合并指标
30 天内没有已合并 PR

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

swagger-api/swagger-parser 的其他 Issue

查看 swagger-api/swagger-parser 的全部 Issue

相似的 Issue

更多 Java Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。