Skip to content

Invalid openapi.yaml produces unexpected diagnostic message #794

@MaxDesiatov

Description

@MaxDesiatov

Description

When a typo is made or a wrong property name is used in openapi.yaml schema declaration, no relevant diagnostic message is provided when running swift package generate-code-from-openapi. The only error message seen is this one:

Targets with names FooTarget don't contain any config or OpenAPI document files with expected names. 

This message is incorrect, since both config and OpenAPI document are provided in the expected location. The actual underlying reason is that the OpenAPI document didn't pass validation, but validation diagnostic is not produced, which is very confusing.

Reproduction

Create an OpenAPI document that uses int and double types in the schema instead of integer and number:

openapi: '3.1.0' info: title: GreetingService version: 1.0.0 servers: - url: https://example.com/api description: Example service deployment. paths: /summary: get: operationId: getSummary parameters: - name: name required: false in: query description: The name used in the returned greeting. schema: type: string responses: '200': description: A success response with a greeting. content: application/json: schema: $ref: '#/components/schemas/Greeting' components: schemas: Greeting: type: object properties: message: type: string floatingPoint: type: double integerValue: type: int

Package version(s)

 "location" : "https://github.com/apple/swift-openapi-generator.git", "state" : { "revision" : "ea291f05436363665ee67c453f4a72a895f18e75", "version" : "1.9.0" }

Expected behavior

If openapi.yaml doesn't pass validation, a validation error should be produced, ideally with line/column information and an actionable suggestion for how the error can be fixed.

Environment

> swift --version swift-driver version: 1.120.5 Apple Swift version 6.1.2 (swiftlang-6.1.2.1.2 clang-1700.0.13.5) Target: arm64-apple-macosx15.0 

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugFeature doesn't work as expected.status/triageCollecting information required to triage the issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions