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

Fix compiler-rs #3083

Merged
merged 3 commits into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"
}
}
Loading