Skip to content

Conversation

@osfameron
Copy link
Collaborator

I'll need to merge this in to get the "Vale review of OpenAPI files in Capella repo" feature deployed.

If you have time to check, let me know if you see any issues!
(No worry if not, I'll make good any regressions.)

These Views are customized to either:
  - `description` at top-level (Included)
  - `properties.*.description`

This requires us to explicitly tell Vale which files are of which type in the .vale.ini
like this example:

```
[cmd/cp-open-api/specs/schemas/alertIntegration/{BasicAuth,*AlertIntegration*,Exclude,Reque
st*, Response*}.yaml]
BasedOnStyles = Vale, write-good, proselint, Couchbase, Google
View = OpenAPI

[cmd/cp-open-api/specs/schemas/alertIntegration/{Token}.yaml]
BasedOnStyles = Vale, write-good, proselint, Couchbase, Google
View = OpenAPIInclude
```

(This restriction may go away with dasel 3, once Vale integrates that)
It looks like the behaviour of Vale with dasel view of a Yaml file
gives inconsistent results for Line and Span.

EXPECT:
======
the .Line and .Span records should point to the location in the file that
the .Match text comes from.

ACTUAL:
======
* For .adoc, this expectation is true.

* For rules like Couchbase.VentilatedProse (theory: with `scope: raw`),
we instead get the .Line indexed from the position of the Yaml token selected.

For example, on the first line of the `.description`, it is marked as Line: 1

* For rules like Vale.Terms, we do get the correct .Line, but the .Span is indexed based on *YAML*'s understanding of the parsed content, not the textual source of the .yaml file contents.
Copy link
Contributor

@sarahlwelton sarahlwelton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure how intelligent most of my comments are after like 10 minutes of research but lemme know I guess 😅


attribute-missing = drop

Vale.Spelling = NO
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious why we don't want to run spellcheck?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question!
There were a lot of false positives, and it made testing very noisy.
I think the correct thing would be to add a vocabularies/CapellaOpenAPI.txt and update those such that there's a canonical list of words used. (Some of these might also go into our Couchbase.txt list, but I think it's worth keeping some hygiene between them.)

I'd like to do this as a subsequent step, rather than making it a blocker though.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense to me. Our current vocabularies aren't very fleshed out, so might be worth investing some time into those in general.

BasedOnStyles = Vale, write-good, proselint, Couchbase, Google

Vale.Spelling = NO
[test/fixtures/test.yml]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is only going to limit to files called test.yml. Is that going to work for where you want to deploy this? Shouldn't we just specify the yml file extension generally, instead?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, this is just a sample test.yml file, for the purpose of testing the infrastructure.
(It's actually proving that Vale+Views+Dasel Yaml mangles the line numbers... I've submitted a bug-report)

The customized .vale.ini then lives in the content repo, currently a POC one https://github.com/couchbaselabs/docs-vale-openapi-test-poc/blob/master/cmd/cp-open-api/specs/.vale.ini

That's because there's some mangling for specific files needing a specific view (again, to work around a Vale+Views+dasel bug/misfeature) which I don't think needs to go in the central .vale.ini.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh my, that .ini seems a little fragile - I hope that bug fix makes that easier to manage going forward.

Comment on lines +46 to +48
catch (err) {
console.log("Failed to run vale", err)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Damn, does Vale not give more specific errors to try and map onto, or is this just for a quick and dirty approach?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not expecting the vale invocation to fail, so this just passes the error back to us so we can understand what happened (usually it'll be because I got the command parameters wrong).

Comment on lines +13 to +15
describe('check spans for Asciidoc', function () {
testSpans('test/fixtures/basic.adoc')
})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this just for testing? Just curious why we have a test for checking for AsciiDoc.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, just:

  1. Confirm that my expectation that .Line and .Span should identify the string in the source file actually works for .adoc
  2. Having done that lets us know that the logic for checking the files is correct, and therefore a yaml failure is meaningful! (That's important because it's so easy to get off-by-one errors, I could easily have been checking the wrong text.)
  3. Codify the .adoc expectation as a regression test so we notice if the Vale project ever breaks that understanding.

engine: dasel
scopes:
- expr: properties.all().property(description?)
type: md
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does md just make linting this easier? Just curious.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OpenAPI descriptions are specified as Markdown I think?

Vale.Spelling = NO
[test/fixtures/test.yml]
BasedOnStyles = Vale, write-good, proselint, Couchbase, Google
View = OpenAPIInclude
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reading the Vale docs - you've only included one of the .yml files you added for defining a view? Does the other one not work?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's the only view that's relevant for this file. See the POC .vale.ini linked above for more examples

@@ -0,0 +1,4 @@
engine: dasel
scopes:
- expr: properties.all().property(description?)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this proper Dasel syntax? What are you trying to extract with this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -0,0 +1,4 @@
engine: dasel
scopes:
- expr: description
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this might work for the very simple yml - do we want to make it more complex for the yml we're actually going to be linting? 🤔

Copy link
Collaborator Author

@osfameron osfameron Oct 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an actual usecase!

https://github.com/couchbasecloud/couchbase-cloud/blob/main/cmd/cp-open-api/specs/schemas/backups/GetBackupByIDResponse.yaml is an example of OpenAPI.yml (.properties.*.description)

https://github.com/couchbasecloud/couchbase-cloud/blob/main/cmd/cp-open-api/specs/schemas/backups/Method.yaml is an example of this OpenAPIInclude.yml (.description)

The ideal would be expr: ..description which should be possible one Vale integrates the latest Dasel v3 with that feature added.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, didn't realize that Vale hadn't quite caught up to the latest Dasel. Makes sense then.

@osfameron osfameron merged commit 85c8e60 into main Oct 9, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants