Skip to content

Commit

Permalink
Fix compiler-rs (#3083)
Browse files Browse the repository at this point in the history
  • Loading branch information
pquentin authored Nov 8, 2024
1 parent 17693a6 commit aafe443
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 2 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/compiler-rs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Cargo Build & Test

on:
pull_request:

env:
CARGO_TERM_COLOR: always

jobs:
build_and_test:
name: compiler-rs
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Use Node.js 20
uses: actions/setup-node@v4
with:
node-version: 20

- name: Install deps
run: |
make setup
make generate
make transform-to-openapi
make transform-expand-generics
- name: Install Rust
run: rustup update stable && rustup default stable

- run: cargo build --verbose
working-directory: compiler-rs

- run: cargo test --verbose
working-directory: compiler-rs
9 changes: 9 additions & 0 deletions compiler-rs/clients_schema/src/transform/expand_generics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,15 @@ pub fn expand(model: IndexedModel, config: ExpandConfig) -> anyhow::Result<Index
itf.inherits = Some(expand_inherits(inherit, &mappings, model, ctx)?);
}

if !itf.behaviors.is_empty() {
itf.behaviors.iter().for_each(|b| {
if b.generics.is_empty() {
// If the behavior has no generics, we can just expand it
let _ = expand_type(&b.typ, Vec::new(), model, ctx);
}
});
}

// We keep the generic parameters of behaviors, but expand their value
for behavior in &mut itf.behaviors {
for arg in &mut behavior.generics {
Expand Down
Binary file modified compiler-rs/compiler-wasm-lib/pkg/compiler_wasm_lib_bg.wasm
Binary file not shown.
4 changes: 3 additions & 1 deletion compiler-rs/openapi_to_clients_schema/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ fn generate_type_for_schema(
})
}
if let Some(ref docs) = data.external_docs {
base.ext_doc_url = Some(docs.ext_docs_url.clone())
base.ext_doc_url = Some(docs.url.clone())
}

// TODO: data.readonly/writeonly -> OverloadOf?
Expand Down Expand Up @@ -402,6 +402,8 @@ fn generate_interface_def(
required: required.contains(&name),
doc_id: None,
doc_url: None,
ext_doc_id: None,
ext_doc_url: None,
codegen_name: None, // FIXME: extension in workplace search
description: None,
aliases: Vec::default(),
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"dependencies": {
"@stoplight/spectral-cli": "^6.13.0"
"@stoplight/spectral-cli": "^6.13.1"
}
}

0 comments on commit aafe443

Please sign in to comment.