Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fails to parse yaml values with double quote " inside #2631

Open
pomali opened this issue Jun 3, 2024 · 4 comments
Open

fails to parse yaml values with double quote " inside #2631

pomali opened this issue Jun 3, 2024 · 4 comments
Labels
p/low t/bug Something isn't working triaged

Comments

@pomali
Copy link

pomali commented Jun 3, 2024

Describe the bug
when linting yaml file, value containing double quote " does not get recognized as string

To Reproduce

  1. Given this OpenAPI document
    a.yaml
openapi: 3.0.3
info:
  title: A
  version: 0.1.0
  description: "A"
paths:
  /api/device/apns/:
    get:
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaginatedAPNSDeviceList'
          description: ''
components:
  schemas:
    PaginatedAPNSDeviceList:
      type: object
      required:
      - results
      properties:
        next:
          type: string
          nullable: true
          format: uri
          example: http://api.example.org/accounts/?cursor=cD00ODY%3D"

and .spectral.yaml

extends: ["spectral:oas"]
  1. Run this CLI command spectral lint a.yaml
  2. See error
...
 27:20    error  oas3-valid-schema-example    "example" property must match format "uri"                     components.schemas.PaginatedAPNSDeviceList.properties.next.example

this is caused by " in example. (same arror can happen with oas3-valid-media-example)

Expected behavior
other yaml libraries (eg. pyyaml) recognize not-leading double quote and treat the value like a string, so it should not fail the validation (since format: uri gets downgraded to type: string, which should match, and if format: uri is recognized it should be valid anyway)

@daniel-white
Copy link
Member

is the quote intended to be part of the URL string value or part of the yaml syntax?

@pomali
Copy link
Author

pomali commented Jun 14, 2024

Pyyaml recognizes it as part of URL string value

@ponelat ponelat added t/bug Something isn't working p/low triaged labels Jul 22, 2024
@ponelat
Copy link

ponelat commented Jul 22, 2024

Thanks @pomali do you know if (and which) part of the YAML specification non-leading quotes may be part of?

@pomali
Copy link
Author

pomali commented Jul 22, 2024

Thanks @pomali do you know if (and which) part of the YAML specification non-leading quotes may be part of?

I'm not even sure if it's part of specification, but seems reasonable that linter should be able to read such malformed yaml, or throw some better error.

My guess would be that it's interpreted as Flow Plain Style so double-quote " has no special meaning there, but I'm just casual yaml user.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p/low t/bug Something isn't working triaged
Projects
None yet
Development

No branches or pull requests

3 participants