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

Invalid Error when parsing a schema with a field type string + format #482

Closed
LasneF opened this issue Apr 12, 2024 · 2 comments
Closed
Labels
bug Something isn't working needs investigation

Comments

@LasneF
Copy link

LasneF commented Apr 12, 2024

Taking the snippet below , vaccum CLI return a error

.\component-descriptor.yml:26:7  | error    | schema `format` should be a ECMA-262 regular expression dialect   | oas-schema-check      | Schemas 
     | $.components.schemas['PetPot'].format

The issue is : format is not supposed to be ECMA-262 , but part of a dictionnary (taken from JSON schema definition + OAS registry https://spec.openapis.org/registry/format/

the registry can be also retreived as code leveraging : https://spec.openapis.org/api/format.json

if you want to apply such rules , ECMA validation, it has to be done on the attribute pattern not format

Conclusion :

  • i should not have an error, neither a warning (could be but difficult) ,
  • format registry validation can be interesting but can lead only to an inform statement as the registry is not limited ,
openapi: '3.1.0'
info:
  title: this is the title
  description: this is the description
  version: '1.0'
servers:
  - url: https://api.server.test/v1

paths:
  /test:
    get:
      operationId: getTest
      responses:
        '200':
          "description" : "testOK"
          "content":
            "application/json": 
              "schema": 
                  "$ref": "#/components/schemas/PetPot"
              

components:
  schemas:
    PetPot:
      type : string
      format: ^[0-9]+*
@daveshanley daveshanley added bug Something isn't working needs investigation labels Apr 12, 2024
@daveshanley
Copy link
Owner

Hmm.. I remember being careful when I built this, but I need to circle back and double check

daveshanley added a commit that referenced this issue Apr 21, 2024
pattern is now checked, not format. silly me!
@daveshanley daveshanley mentioned this issue Apr 21, 2024
daveshanley added a commit that referenced this issue Apr 21, 2024
pattern is now checked, not format. silly me!
@daveshanley
Copy link
Owner

This has been fixed in v0.9.15 The pattern property is now correctly checked instead of format thank you for finding this!

https://github.com/daveshanley/vacuum/blob/main/functions/openapi/schema_type_test.go#L151

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

No branches or pull requests

2 participants